-
Notifications
You must be signed in to change notification settings - Fork 210
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
Cookbook recipe for demos with Gradio. #133
Cookbook recipe for demos with Gradio. #133
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
cc/ @MoritzLaurer |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
@@ -0,0 +1,5796 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW one thing cool about gradio is it has direct integration with transformers, so you can call gr.Interface.load()
here instead of calling pipeline and then Interface. and for more complex second part you could do a bare function and then pass inside Interface.
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By this you mean direct integration with the Hub right? Ie load
works for models in the hub already.
I wanted to feature this as well (in fact it was part of my original writeup) but I ended up thinking it would make this recipe too long. Maybe I can add a TIP
mention in this part to point readers to the load
feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this fails
gr.load(
"distil-whisper/distil-large-v3",
src="models",
inputs=gr.Audio(type="filepath"), # "filepath" passes a str path to a temporary file containing the audio
outputs=gr.Textbox(show_copy_button=True), # give users the option to copy the results).launch()
).launch(debug=True)
w/ the following traceback:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/gradio/queueing.py", line 532, in process_events
response = await route_utils.call_process_api(
File "/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py", line 276, in call_process_api
output = await app.get_blocks().process_api(
File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1928, in process_api
result = await self.call_function(
File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1514, in call_function
prediction = await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 832, in wrapper
response = f(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/gradio/external.py", line 371, in query_huggingface_inference_endpoints
data = fn(*data) # type: ignore
File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/inference/_client.py", line 415, in automatic_speech_recognition
response = self.post(data=audio, model=model, task="automatic-speech-recognition")
File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/inference/_client.py", line 273, in post
hf_raise_for_status(response)
File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_errors.py", line 371, in hf_raise_for_status
raise HfHubHTTPError(str(e), response=response) from e
huggingface_hub.utils._errors.HfHubHTTPError: 413 Client Error: Payload Too Large for url: https://api-inference.huggingface.co/models/distil-whisper/distil-large-v3 (Request ID: eWMj4weC7hhXnrCKf_p-d)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apparently in recent version of gradio this was swapped with from_pipeline
which is essentially transformers integration for gradio. it doesn't need to call any API whatsoever it just loads the model and the pipeline into an Interface by inferring their i/o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you! added a TIP
highlighting that constructor
@@ -0,0 +1,5796 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what you are referring to here re: share?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant one does demo.launch(share=True)
when you want to set a tunnel, but this shouldn't be when gradio is ran in Spaces.
@@ -0,0 +1,5796 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add this at the end, I feel like further readings in middle of pages divert readers' attention a lot
Reply via ReviewNB
@@ -0,0 +1,5796 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also add an intro to Blocks
API to this recipe, it's more fundamental than features like flagging IMHO
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skipping this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left very general comments, thank you for this recipe!
@@ -0,0 +1,5796 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice demonstration of a transcription tool! 👏
This reverts commit bae2d39.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! I think once the toctree is resolved, we can merge! 🥳
What does this PR do?
Recipe to create demos with Gradio for the HF Enterprise Cookbook.
Who can review?
@stevhliu