Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with CURL Request in Downloader.php #40

Closed
1 of 4 tasks
BlackyDrum opened this issue Jun 4, 2024 · 1 comment · Fixed by #41
Closed
1 of 4 tasks

Problem with CURL Request in Downloader.php #40

BlackyDrum opened this issue Jun 4, 2024 · 1 comment · Fixed by #41
Assignees
Labels
bug Something isn't working

Comments

@BlackyDrum
Copy link
Contributor

System Info

Windows 10, PHP built-in Webserver, Laravel 11

PHP Version

8.3.1

Environment/Platform

  • Command-line application
  • Web application
  • Serverless
  • Other (please specify)

Description

If the config.json file for a model does not yet exist, I encounter the following error:

Codewithkyrian\Transformers\Utils\AutoConfig::__construct(): Argument #1 ($config) must be of type array, null given, called in C:\Users\Gani\Desktop\transformers\vendor\codewithkyrian\transformers\src\Utils\AutoConfig.php on line 53

However, if the config.json file for a model does exist, I get this error:

Error 0 occurred while trying to load file from https://huggingface.co\Xenova/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/onnx\model_quantized.onnx

The issue seems to stem from this line in the code for me:

// Downloader.php
curl_setopt($curlHandle, CURLOPT_URL, $url);

When I dump the value of $url, it appears correct:

https://huggingface.co\Xenova/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/config.json

However, when I dump the URL using curl_getinfo($curlHandle), the URL value is:

https://huggingface.co\\Xenova/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/config.json

It seems the backslash character is being escaped for me. The line $error = curl_error($curlHandle); also indicates a hostname error:

Log::info($error); -> URL rejected: Bad hostname

For me it worked when I changed this:

// Downloader.php
curl_setopt($curlHandle, CURLOPT_URL, $url);

to this:

curl_setopt($curlHandle, CURLOPT_URL, str_replace('\\', '/', $url));

This fixed both errors for me. However, this issue with the backslash being escaped might be specific to my configuration (although I don't know how), and I'm not certain if it occurs for others aswell.

Reproduction

  1. $classifier = pipeline('sentiment-analysis');
  2. $result = $classifier('I love everything!');
@BlackyDrum BlackyDrum added the bug Something isn't working label Jun 4, 2024
@CodeWithKyrian CodeWithKyrian self-assigned this Jun 5, 2024
@CodeWithKyrian
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants