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

Fix InferenceAPI on image task #1270

Merged
merged 3 commits into from
Dec 15, 2022
Merged

Fix InferenceAPI on image task #1270

merged 3 commits into from
Dec 15, 2022

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Dec 15, 2022

Related to slack discussion (internal link).

  • text-to-image now works by returning a Pillow image (if PIL is installed, otherwise you get an ImportError).
  • if content type is application/json or image/jpeg => we parse the output. Otherwise raise NotImplementedError. This is in particular the case for text-to-speech tasks.
  • the InferenceAPI has now a kwarg raw_response: bool = False. If True, we return the full Response object to the user. At least this way if we don't handle a task yet, the user can build its own parser (typically for audio).
  • adapted/fixed some stuff (now sending user agent in request for example)
  • => added 2 examples in the doc and some tests

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Dec 15, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@osanseviero osanseviero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

src/huggingface_hub/inference_api.py Show resolved Hide resolved
src/huggingface_hub/inference_api.py Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Dec 15, 2022

Codecov Report

Base: 82.26% // Head: 83.90% // Increases project coverage by +1.63% 🎉

Coverage data is based on head (7ceef22) compared to base (d147cbd).
Patch coverage: 76.19% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1270      +/-   ##
==========================================
+ Coverage   82.26%   83.90%   +1.63%     
==========================================
  Files          47       47              
  Lines        4596     4609      +13     
==========================================
+ Hits         3781     3867      +86     
+ Misses        815      742      -73     
Impacted Files Coverage Δ
src/huggingface_hub/utils/__init__.py 100.00% <ø> (ø)
src/huggingface_hub/utils/_runtime.py 62.38% <60.00%> (-0.12%) ⬇️
src/huggingface_hub/inference_api.py 90.90% <81.25%> (+2.02%) ⬆️
src/huggingface_hub/repository.py 78.76% <0.00%> (+13.27%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Wauplin
Copy link
Contributor Author

Wauplin commented Dec 15, 2022

Thanks for the review @osanseviero ! I've added the docstring and will now merge :)

@Wauplin Wauplin merged commit a2b6d3f into main Dec 15, 2022
@Wauplin Wauplin deleted the fix-inference-api-image-task branch December 15, 2022 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants