Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files28 unmodified lines293031323334385 unmodified lines42042142242328 unmodified linesimport spaces # type: ignoreimport gradio as grROOT_DIR = Path(__file__).resolve().parentsys.path.insert(0, str(ROOT_DIR))385 unmodified linesif __name__ == "__main__":demo.queue().launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", "7860")))28 unmodified lines2930313233343536373839404142434445464748495051525354555657585960616263646566385 unmodified lines45245345445545645745845946046128 unmodified linesimport spaces # type: ignoreimport gradio as gr# --------------------------------------------------------------------------- ## Monkey-patch for a known Gradio 4.44 / gradio_client bug: when the API-info# endpoint builds a schema for an output that includes `additionalProperties:# True` (a bool, not a dict), `gradio_client.utils.get_type()` tries# `"const" in schema` and raises `TypeError: argument of type 'bool' is not# iterable`. Our `gr.JSON` output lands in that code path on first page load# and crashes the whole Space. Wrap `get_type` so any non-dict schema resolves# to the permissive "Any" type. Has no effect on well-typed schemas.# --------------------------------------------------------------------------- #try:import gradio_client.utils as _gc_utils # noqa: E402_orig_get_type = _gc_utils.get_typedef _safe_get_type(schema): # type: ignore[no-redef]if not isinstance(schema, dict):return "Any"return _orig_get_type(schema)_gc_utils.get_type = _safe_get_type # type: ignore[assignment]_orig_json_schema_to_python_type = _gc_utils._json_schema_to_python_typedef _safe_json_schema_to_python_type(schema, defs=None): # type: ignore[no-redef]if not isinstance(schema, dict):return "Any"return _orig_json_schema_to_python_type(schema, defs)_gc_utils._json_schema_to_python_type = _safe_json_schema_to_python_type # type: ignore[assignment]except Exception as _exc: # noqa: BLE001print(f"[v5] gradio_client get_type patch skipped: {_exc}")ROOT_DIR = Path(__file__).resolve().parentsys.path.insert(0, str(ROOT_DIR))385 unmodified linesif __name__ == "__main__":# On HF Gradio Spaces (including ZeroGPU) the platform runs `python app.py`# and expects `demo.launch()` with no explicit server_name/port — the# `spaces/zero/gradio.py` launch wrapper binds the port itself. Passing# `server_name="0.0.0.0"` triggers the "localhost not accessible" self-# check inside Gradio and crashes startup. Locally, `demo.launch()` still# serves on 127.0.0.1:7860 by default.demo.queue().launch(show_api=False)
app.py+39-1