Spaces:
Sleeping
Sleeping
| """ | |
| Hugging Face Spaces 入口 | |
| """ | |
| import sys | |
| # -------------------------------------------------- | |
| # 补丁 1: audioop (Python 3.13) | |
| # -------------------------------------------------- | |
| try: | |
| import audioop_lts as audioop | |
| sys.modules["pyaudioop"] = audioop | |
| except ImportError: | |
| pass | |
| # -------------------------------------------------- | |
| # 补丁 2: HfFolder (huggingface-hub>=0.25) | |
| # -------------------------------------------------- | |
| try: | |
| import huggingface_hub | |
| if not hasattr(huggingface_hub, "HfFolder"): | |
| from huggingface_hub import get_token | |
| class _HfFolder: | |
| def get_token(): return get_token() | |
| huggingface_hub.HfFolder = _HfFolder | |
| sys.modules["huggingface_hub"].HfFolder = _HfFolder | |
| except Exception: | |
| pass | |
| # -------------------------------------------------- | |
| # 补丁 3: Gradio 5.0.0 bug - additionalProperties 布尔值 | |
| # -------------------------------------------------- | |
| try: | |
| import gradio_client.utils as gcu | |
| _orig = gcu._json_schema_to_python_type | |
| def _patched(schema, defs=None): | |
| if isinstance(schema, bool): | |
| return "any" | |
| return _orig(schema, defs) | |
| gcu._json_schema_to_python_type = _patched | |
| # 也 patche get_type 以防被直接调用 | |
| if hasattr(gcu, "get_type"): | |
| _orig_get = gcu.get_type | |
| def _patched_get(schema): | |
| if isinstance(schema, bool): | |
| return "any" | |
| return _orig_get(schema) | |
| gcu.get_type = _patched_get | |
| except Exception: | |
| pass | |
| # -------------------------------------------------- | |
| # 启动 | |
| # -------------------------------------------------- | |
| from webui import demo | |
| demo.queue().launch(server_name="0.0.0.0", server_port=7860) | |