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.

5 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

For anyone looking into the “Your space is in error, check its status on hf. co” errors: no, it is not your browser, or settings, or adblock.

In the intro to the chapter ( Introduction to Gradio - Hugging Face LLM Course ) 2/3 demos that are supposed to show sharing models are broken. I looked in logs and it seems that fetching (course-demos-remove-bg-original.hf.space) breaks it. I tried following it to ( Remove Bg Original - a Hugging Face Space by course-demos ) and there seems to be a build error.

Actually, looking into other elements in the demos it seems that there are many build errors there.

1 Like

Too many error, while launching Space/Hub locally,

  1. it does not support title, description error
  2. even not support .launch()
  • TypeError: EventListener._setup..event_trigger() got an unexpected keyword argument ‘title’

what is going on, i’m using gradio 5.50.0 version on 7 December 2025.

1 Like

With Gradio, there are occasional compatibility issues between different versions. Especially when major versions (3, 4, 5, 6…) differ, compatibility is almost nonexistent.


You’re seeing two separate but related breakages:

  1. Old course / Space code that assumes Gradio 3.x–early 4.x.
  2. A new Gradio 5.50.0 runtime with a stricter event system and a different Interface.load behavior.

Those collide and produce:

  • TypeError: EventListener._setup..event_trigger() got an unexpected keyword argument 'title'
  • 'Dependency' object has no attribute 'launch'

Below: causes first, then concrete fixes with example code.


1. Background: what changed in Gradio

1.1 The course code is from 2022

The Hugging Face course Chapter 9 page (“Integrations with the Hugging Face Hub”) shows examples like:

gr.Interface.load(
    "huggingface/EleutherAI/gpt-j-6B",
    inputs=gr.Textbox(lines=5, label="Input Text"),
    title="Text generation",
).launch()

and

gr.Interface.load("spaces/abidlabs/remove-bg").launch()

That material dates from ~2022 and assumes the Gradio 3.x API.

1.2 Interface.load is being phased out

Old docs for Gradio 3.x/4.x already had a warning: (CSDN)

  • gradio.Interface.load(...) will be deprecated.
  • Use gradio.load(...) instead.

So even before Gradio 5, the project was already steering people away from Interface.load.

1.3 Gradio 5 introduces a stricter event system

The “Migrating to Gradio 5” note explains a key behavior: if you pass an unsupported keyword into an event, you get:

EventListener._setup.<locals>.event_trigger() got an unexpected keyword argument 'every'

In other words:

  • Events now have a fixed signature.
  • Old extra keywords (every, _js, concurrency_count, etc.) cause exactly that event_trigger TypeError.

You are seeing the same pattern, just with the keyword title.

1.4 Gradio 5.50 is the “pre-Gradio-6” clean-up release

The Gradio 6 migration guide says explicitly: upgrade to 5.50 to see deprecation warnings and breakages for anything removed in 6.0.

So:

  • 5.50.0 is intentionally stricter.
  • It exposes old, unsupported patterns that the 2022 course still uses.

2. Cause 1: event_trigger() got an unexpected keyword 'title'

2.1 What you are running

Typical failing line (from your thread and the HF forum):

gr.Interface.load(
    "spaces/abidlabs/remove-bg",
    inputs="webcam",
    title="Remove your webcam background!",
).launch()

You see:

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

2.2 How Interface.load works now

The implementation for Interface.load in the 4.x line already became a very overloaded method: class method + instance method sharing the same name. The docs show: (CSDN)

  • As a class method, it loads a demo from a Hub repo (model or Space).
  • As an instance method, it acts as an event: “run this function when the interface loads in the browser.”

You can see from the real code snippet (4.x blocks.py) that the method signature looks like:

load(fn=None, inputs=None, outputs=None, every=None, _js=None, *, name=None, src=None, api_key=None, alias=None, **kwargs)

The key points:

  • When used as an event, load becomes an event listener wired into the new event system.
  • That event listener internally calls event_trigger(...).
  • event_trigger only knows about a limited set of parameters (fn_index, request data, etc.), not arbitrary kwargs like title or description. (Gradio)

With the modern event system in Gradio 5:

  • Any unexpected kwarg (every, _js, title, concurrency_count, etc.) that slips into that call produces the TypeError you see.

2.3 Why title ends up there

In the old 3.x mental model:

  • Interface.load(name, inputs=..., title=...) would build an Interface and forward title to the constructor.

In the current code path:

  • Interface.load is trying to be both “load a Space” and “register a load event”.
  • Extra kwargs like title are no longer consistently routed to Interface.__init__.
  • Some calls end up treating load as an event listener, and the kwargs go into event_trigger.
  • event_trigger’s signature does not include title, so Python raises the TypeError.

So the root cause of your title error:

You are passing UI kwargs (title, description, etc.) through Interface.load, which in Gradio 5.50 is wired into the event system. Those kwargs reach event_trigger, which does not accept them, so it throws unexpected keyword 'title'.

The problem is not “Gradio removed titles entirely”. The problem is where you are passing them.


3. Cause 2: .launch() “not supported” after Interface.load(...)

The second symptom is:

gr.Interface.load("spaces/abidlabs/remove-bg").launch()

raising something like:

AttributeError: 'Dependency' object has no attribute 'launch'

This is the error reported in several places:

  • GitHub issue “Interface.load fails” for model repos. (CSDN)
  • NVIDIA NeMo issue: Interface.load("models/nvidia/stt_en_fastconformer_transducer_xlarge").launch() → same AttributeError.
  • HF model microsoft/kosmos-2-patch14-224: identical 'Dependency' object has no attribute 'launch' when using Interface.load(...).launch().

What happened:

  • In older versions, Interface.load returned an Interface or Blocks object.
  • .launch() is defined on Interface and Blocks.
  • In newer versions, Interface.load often returns a Dependency object (an internal graph node representing “call this external interface”), not a full app. That object has no .launch() method.

So the root cause here:

You are calling .launch() on the wrong type. Interface.load no longer guarantees that it returns a launchable Interface; for Hub repos it often returns a Dependency, which is not launchable.

That is why all the modern docs show gr.load(...).launch(), not Interface.load(...).launch().


4. Cause 3: other removed/changed keywords (allow_screenshot, interpretation, etc.)

In the same course thread and in real Spaces, you see errors like:

  • BlockContext.__init__() got an unexpected keyword argument 'allow_screenshot'
  • BlockContext.__init__() got an unexpected keyword argument 'interpretation'
  • And in other issues: fill_height, etc., also rejected.

Example from a live Space (taesiri/LatexDiff): the logs show:

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

Explanation:

  • Those parameters existed in older Gradio releases in Interface / Blocks constructors.
  • They were later removed or reworked; they are not in the current Interface/Blocks docs.
  • When you pass them now, Python complains at BlockContext.__init__.

Same pattern as title in your error: the keyword is no longer accepted in that location.


5. Causes summary, in one place

Putting it together:

  1. The HF course (2022) examples rely on old Gradio APIs:

    • Interface.load(...).launch() for Hub / Spaces.
    • Deprecated keywords like allow_screenshot, interpretation, etc.
  2. Gradio 5.50.0 has:

    • A stricter event system; extra kwargs to events trigger event_trigger(...unexpected keyword...).
    • A changed Interface.load that can return Dependency instead of a launchable Interface. (CSDN)
  3. Your specific errors are just concrete instances of that mismatch:

    • title passed through Interface.load → leaks into event_trigger → TypeError. (Gradio)
    • .launch() called on the object from Interface.load → object is Dependency, not Interface → AttributeError. (CSDN)

6. Solutions: two main strategies

You have two realistic paths.

Strategy A: Make the code match your new Gradio (stay on 5.50.0)

This is better long-term.

6.1 Use gr.load, not Interface.load, for Hub / Spaces

Modern docs and the “Hugging Face integrations” guide show the recommended pattern:

import gradio as gr

# Load a Space
demo = gr.load("spaces/abidlabs/remove-bg")
demo.launch()

# Load a model repo
demo = gr.load("huggingface/EleutherAI/gpt-j-6B", src="models")
demo.launch()

Key points:

  • gr.load returns a launchable app (Interface or Blocks), not a Dependency.
  • .launch() is valid on that return value.
  • You usually do not pass title/description into gr.load when loading someone else’s Space; the Space controls its own UI.

So:

  • Replace every gr.Interface.load("spaces/...").launch() with gr.load("spaces/...").launch().
  • For models, use gr.load("repo-id", src="models").

6.2 When you want custom title / description, build the Interface yourself

For your own app (not someone else’s Space), do:

import gradio as gr

def predict(text):
    return text.upper()

demo = gr.Interface(
    fn=predict,
    inputs=gr.Textbox(lines=3, label="Input text"),
    outputs="text",
    title="My demo",
    description="Local Gradio app with title and description.",
)

demo.launch()

According to the current Interface docs, title and description are valid constructor arguments.

The rule:

  • Put UI config (title, description, etc.) on Interface(...) or Blocks(...), not on event listeners and not via Interface.load.

6.3 Strip or migrate deprecated keywords

If you run course/Space code and hit errors like:

  • BlockContext.__init__() got an unexpected keyword argument 'allow_screenshot'
  • BlockContext.__init__() got an unexpected keyword argument 'interpretation'
  • Blocks.queue() got an unexpected keyword argument 'concurrency_count'

then:

  • Remove those keywords entirely, or
  • Replace them with whatever the current docs say (for queue, use concurrency_limit instead of concurrency_count. )

For events:

  • If you see every=... in a .load(), .click(), etc., Gradio 5 says clearly: event listeners no longer support every. Replace it with gr.Timer().tick(...) as described in the migration note.
  • If you see _js=... in event listeners, that pattern is obsolete; newer examples use js= or different mechanisms. The _js variant gives the same event_trigger error in recent threads. (Gradio)

6.4 When the Space itself is broken

If a Space’s own app.py uses invalid keywords (like allow_screenshot in LatexDiff):

  • You cannot fix that just by changing how you load it.

  • Options:

    • Fork the Space, clone it, edit its app.py to remove old keywords, and run your fork.
    • Or open an issue / PR on that Space asking the author to update for Gradio 5+.

Loading a broken Space with gr.load will still break; your loader is fine, their app is not.


Strategy B: Make Gradio match the old code (downgrade)

If your goal is “run the HF course notebooks exactly as written with minimal edits”, you can instead pin an older Gradio version.

Example:

pip install "gradio==4.44.1"

Gradio 4.44.1 docs still describe both gr.load and Interface.load as supported ways to load a Hub repo, with Interface.load specifically marked “will be deprecated; use gradio.load() instead”. (CSDN)

This makes:

  • Interface.load(...).launch() much more likely to work as in the course.
  • Some older keywords (allow_screenshot, interpretation) might still be accepted, depending on the exact version the course targeted.

Trade-offs:

  • You lose newer features and fixes from Gradio 5/6.
  • Anything that already expects Gradio 5 APIs (newer Spaces, libraries) might break on 4.x.

If you go this route:

  1. Create a separate virtualenv just for the course.
  2. Install a fixed Gradio version there (e.g., 4.44.1).
  3. Run the course notebooks in that env.

7. Concrete “do this now” checklist for your setup

You are on Gradio 5.50.0 on 7 Dec 2025.

  1. Stop using Interface.load(...).launch() for Hub things.

    Replace:

    gr.Interface.load("spaces/abidlabs/remove-bg").launch()
    

    with:

    import gradio as gr
    demo = gr.load("spaces/abidlabs/remove-bg")
    demo.launch()
    
  2. Do not pass title / description through Interface.load.

    • If you are loading someone else’s Space, drop those arguments; let the Space define its own UI.

    • If you are building your own app, write:

      demo = gr.Interface(fn=..., inputs=..., outputs=..., title="...", description="...")
      demo.launch()
      
  3. If you see any every=, _js=, concurrency_count=, allow_screenshot=, interpretation=, fill_height= etc.:

    • Assume they are outdated.
    • Look them up in the current Gradio docs or the Gradio 5 migration issue, and either remove or replace them.
  4. If you absolutely want zero code changes, downgrade Gradio inside a dedicated environment to a 4.x version and re-run the course there.


Short bullet summary

  • Cause A (title error): Interface.load in Gradio 5.50 routes extra kwargs through the new event system. title is not a valid event parameter, so event_trigger(..., title=...) throws unexpected keyword 'title'.
  • Cause B (.launch error): Interface.load often returns a Dependency, not an Interface, so calling .launch() on it fails. (CSDN)
  • Cause C (other keyword errors): older keywords (allow_screenshot, interpretation, concurrency_count, etc.) were removed; passing them now hits BlockContext.__init__ or event listener signature errors.
  • Solution path 1 (recommended): stay on Gradio 5.50.0; use gr.load("spaces/...") / gr.load("model", src="models"), build your own Interface(...) for custom titles, and remove outdated kwargs.
  • Solution path 2 (compat mode): pin Gradio to an older 4.x version (e.g., 4.44.1) in a separate environment to run the course notebooks almost as-is, accepting that you’re on a legacy API.