File size: 1,759 Bytes
bf5b4d8
7e18bc7
bf5b4d8
5a2bddd
b8d585a
e03b72a
 
 
5a2bddd
 
f3e0ee9
5a2bddd
 
 
e03b72a
 
 
b8d585a
 
 
7e18bc7
44f15fb
b8d585a
44f15fb
 
 
 
 
f3e0ee9
e03b72a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7e18bc7
e03b72a
44f15fb
7e18bc7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
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:
            @staticmethod
            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)