# Chapter 9 questions

**URL:** <https://discuss.huggingface.co/t/chapter-9-questions/22025>\
**Category:** Course\
**Created:** [August 24, 2022, 8:45am UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025 "2022-08-24T08:45:59Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [August 24, 2022, 8:45am UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/1 "2022-08-24T08:45:59Z")

</div>

Use this topic for any question about [Chapter 9](https://huggingface.co/course/chapter9) of the course.

---

<div class="post-metadata">

**Author:** ![ShadowTwin41](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@ShadowTwin41](https://discuss.huggingface.co/u/ShadowTwin41)\
**Post date:** [September 28, 2022, 10:31am UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/2 "2022-09-28T10:31:33Z")

</div>

Hello Everyone!

I think something is missing in the [Sharing demos with others - Hugging Face Course](https://huggingface.co/course/chapter9/4?fw=pt), namely imports and defining the function:

```auto
fn=predict

```

---

<div class="post-metadata">

**Author:** ![tomjam](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@tomjam](https://discuss.huggingface.co/u/tomjam)\
**Post date:** [October 21, 2022, 6:50am UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/3 "2022-10-21T06:50:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sounique77](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sounique77/32/14140_2.png) [@sounique77](https://discuss.huggingface.co/u/sounique77)\
**Post date:** [February 14, 2023, 9:42pm UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/4 "2023-02-14T21:42:37Z")

</div>

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”),

---

<div class="post-metadata">

**Author:** ![rscherl](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@rscherl](https://discuss.huggingface.co/u/rscherl)\
**Post date:** [August 3, 2023, 9:11pm UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/5 "2023-08-03T21:11:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![albrechtje](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/albrechtje/32/21647_2.png) [@albrechtje](https://discuss.huggingface.co/u/albrechtje)\
**Post date:** [December 12, 2023, 12:17pm UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/6 "2023-12-12T12:17:49Z")

</div>

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

Microphone example:

```python
# 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:

```python
# 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.

---

<div class="post-metadata">

**Author:** ![KevinCN95](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@KevinCN95](https://discuss.huggingface.co/u/KevinCN95)\
**Post date:** [May 17, 2024, 2:36am UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/7 "2024-05-17T02:36:32Z")

</div>

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.”

---

<div class="post-metadata">

**Author:** ![thomaspurk](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@thomaspurk](https://discuss.huggingface.co/u/thomaspurk)\
**Post date:** [January 20, 2025, 8:16pm UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/8 "2025-01-20T20:16:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ZSvedic](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/zsvedic/32/36884_2.png) [@ZSvedic](https://discuss.huggingface.co/u/ZSvedic)\
**Post date:** [February 28, 2025, 12:17pm UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/9 "2025-02-28T12:17:52Z")

</div>

All examples in [Google Colab chapter 9, section 5](https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter9/section5.ipynb) fail to run.  
Exception traces for last 3 cells listed below:

```auto
---------------------------------------------------------------------------
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'

```

```auto
---------------------------------------------------------------------------

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'

```

```auto
---------------------------------------------------------------------------
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](https://huggingface.co/learn/nlp-course/chapter9/5?fw=pt) has HF space embeds that don’t work, the popup says:  
" Something went wrong  
Connection errored out."

---

<div class="post-metadata">

**Author:** ![ZSvedic](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/zsvedic/32/36884_2.png) [@ZSvedic](https://discuss.huggingface.co/u/ZSvedic)\
**Post date:** [February 28, 2025, 12:56pm UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/10 "2025-02-28T12:56:36Z")

</div>

Also two errors in [Google Colab chapter 9, section 6](https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter9/section6.ipynb):

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

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

---

<div class="post-metadata">

**Author:** ![IJSDerbashi](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ijsderbashi/32/54694_2.png) [@IJSDerbashi](https://discuss.huggingface.co/u/IJSDerbashi)\
**Post date:** [October 10, 2025, 7:23am UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/11 "2025-10-10T07:23:15Z")

</div>

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](https://huggingface.co/learn/llm-course/chapter9/1) ) 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](https://huggingface.co/spaces/course-demos/remove-bg-original) ) 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.

---

<div class="post-metadata">

**Author:** ![Rtdon8363737](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@Rtdon8363737](https://discuss.huggingface.co/u/Rtdon8363737)\
**Post date:** [December 7, 2025, 6:09pm UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/12 "2025-12-07T18:09:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [December 8, 2025, 8:35am UTC](https://discuss.huggingface.co/t/chapter-9-questions/22025/13 "2025-12-08T08:35:07Z")

</div>

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:

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

```

and

```python
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](https://blog.csdn.net/fj_changing/article/details/155137600 "windows11部署SoulX-Podcast 原创"))

- `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):

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

```

You see:

```plaintext
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](https://blog.csdn.net/fj_changing/article/details/155137600 "windows11部署SoulX-Podcast 原创"))

- 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:

```python
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](https://www.gradio.app/main/guides/gradio-6-migration-guide "Gradio 6 Migration Guide"))

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:

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

```

raising something like:

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

```

This is the error reported in several places:

- GitHub issue “Interface.load fails” for model repos. ([CSDN](https://blog.csdn.net/fj_changing/article/details/155137600 "windows11部署SoulX-Podcast 原创"))
- 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:

2. **Gradio 5.50.0** has:

3. Your specific errors are just concrete instances of that mismatch:

* * *

## 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:

```python
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:

```python
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](https://www.gradio.app/main/guides/gradio-6-migration-guide "Gradio 6 Migration Guide"))

#### 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:

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:

```bash
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](https://blog.csdn.net/fj_changing/article/details/155137600 "windows11部署SoulX-Podcast 原创"))

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.**

2. **Do not pass `title` / `description` through `Interface.load`.**

3. **If you see any `every=`, `_js=`, `concurrency_count=`, `allow_screenshot=`, `interpretation=`, `fill_height=` etc.:**

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](https://blog.csdn.net/fj_changing/article/details/155137600 "windows11部署SoulX-Podcast 原创"))
- **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.
