# Gradio-specific quirks ## `gr.Progress(track_tqdm=True)` leaks raw library output When the function wrapped by `gr.Progress(track_tqdm=True)` calls into a library that uses `tqdm` internally (model loading via `huggingface_hub`, an inference loop in a model library), Gradio auto-captures those tqdm bars and renders their RAW description text (`"Downloading bytes – 0.0% / Reconstructing (incomplete total...) – 0.0%"`, `"0/250 steps | 5.1s"`) directly in the UI, often duplicated across every output component and overlapping your own status text. This cannot be cleanly restyled with CSS because the text itself (not just its container) is the library's internal wording, and it reappears/re-renders faster than most CSS/JS attempts to hide it can keep up. **Fix: don't track_tqdm; drive progress yourself.** Pass a plain `gr.Progress()` (its `track_tqdm` default is `False` in Gradio 6 — don't pass `True`), and feed it manually: ```python from threading import Event, Thread from time import perf_counter def slow_task(..., progress=gr.Progress()): progress(0.05, desc="Loading model…") ... stop = Event() def _tick(): est_seconds = ... # your own estimate t0 = perf_counter() while not stop.wait(0.4): frac = 0.2 + 0.73 * min(1.0, (perf_counter() - t0) / est_seconds) progress(frac, desc="Working…") ticker = Thread(target=_tick, daemon=True) ticker.start() try: result = blocking_call() # the one thing you can't get real progress from finally: stop.set() ticker.join(timeout=2) progress(1.0, desc="Done") ``` This gives a smoothly animating, honestly-estimated bar with your own clean description text, immune to whatever internal wording the called library happens to print. It is not literally accurate to the model's real internal step count, but it is visually clean and never contradicts itself — which matters more for a non-technical audience than true precision. If some raw progress text still leaks through from elsewhere (a library calling tqdm somewhere Gradio still auto-detects even without `track_tqdm`), add a small cleanup pass via the REAL script-injection entry point (`Blocks(...).launch(js="...")`, not an HTML component — see the main SKILL.md §5) that sweeps the DOM for the offending text pattern and hides the matching leaf element: ```js const raw = /Downloading bytes|Reconstructing|\/\s*\d+\s*steps/; function sweep() { document.querySelectorAll('body *').forEach((el) => { const t = el.textContent || ''; if (t.length < 300 && raw.test(t)) { const childMatch = [...el.children].some((c) => raw.test(c.textContent || '')); if (!childMatch) el.style.display = 'none'; } }); } new MutationObserver(sweep).observe(document.body, { childList: true, subtree: true, characterData: true }); setInterval(sweep, 150); ``` The `childMatch` check is what makes this safe: it hides only the innermost element whose own text matches, never a large ancestor, so it can't accidentally blank out real content. ## `elem_classes` lands on the component's real element, not a wrapper For a `gr.Button`, the class you pass via `elem_classes=[...]` is applied directly to the `