Chapter 9 questions

Use this topic for any question about Chapter 9 of the course.

Hello Everyone!

I think something is missing in the Sharing demos with others - Hugging Face Course, namely imports and defining the function:

fn=predict

" Creating a simple demo using Blocks" " Flip Text! Start typing below to see the output." on the course webpage does not work for me.

It works fine now. But the code for musical notes needs to be changed at the very end so that gr.Textbox(type=“number”, value=1, label=“Duration in seconds”) becomes gr.Textbox(type=“text”, value=1, label=“Duration in seconds”),

I am trying the first Gradio example. When I use GoogleCoLab it works fine. But when I use Sagemaker Studio Lab, nothing appears. Do I need to do something else? The instructions state that when using a notebook, the Gradio display should occur inline. It does with GoogleCoLab, but not with Studio Lab.

There are two errors in the examples, probably related to API changes:

Microphone example:

# old:
mic = gr.Audio(source="microphone", type="numpy", label="Speak here...")
# results in TypeError: Audio.__init__() got an unexpected keyword argument 'source'

# solution
mic = gr.Audio(sources=["microphone"], type="numpy", label="Speak here...")

Tone generation example:

# old
gr.Textbox(type="number", value=1, label="Duration in seconds"),
# gives ValueError: `type` must be one of "text", "password", or "email".

# solution
gr.Number(value=1, label="Duration in seconds"),

There’s also a related error in the speech recognition example which I could not quickly resolve.

4 Likes

There is a typo in the section “Handling multiple inputs and outputs”, which is
“a list of output coponents, each component corresponds to a returned value.”

These corrections are still value and work in a Kaggle notebook 2025-01-20

1 Like

All examples in Google Colab chapter 9, section 5 fail to run.
Exception traces for last 3 cells listed below:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-52644a11c3cf> in <cell line: 0>()
      9     ["The smooth Borealis basin in the Northern Hemisphere covers 40%"],
     10 ]
---> 11 gr.Interface.load(
     12     "huggingface/EleutherAI/gpt-j-6B",
     13     inputs=gr.Textbox(lines=5, label="Input Text"),

TypeError: EventListener._setup.<locals>.event_trigger() got an unexpected keyword argument 'title'
---------------------------------------------------------------------------

AttributeError Traceback (most recent call last)

[<ipython-input-3-e324d6df37d1>](https://localhost:8080/#) in <cell line: 0>() ----> 1 gr.Interface.load("spaces/abidlabs/remove-bg").launch()

AttributeError: 'Dependency' object has no attribute 'launch'
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-fb78e7344564> in <cell line: 0>()
----> 1 gr.Interface.load(
      2     "spaces/abidlabs/remove-bg", inputs="webcam", title="Remove your webcam background!"
      3 ).launch()

TypeError: EventListener._setup.<locals>.event_trigger() got an unexpected keyword argument 'title'

In addition to that page for section 5 has HF space embeds that don’t work, the popup says:
" Something went wrong
Connection errored out."

1 Like

Also two errors in Google Colab chapter 9, section 6:

First example:
TypeError: BlockContext.__init__() got an unexpected keyword argument 'allow_screenshot'

Second example:
TypeError: BlockContext.__init__() got an unexpected keyword argument 'interpretation'

1 Like