AnimeOverlord commited on
Commit
9a09edb
·
1 Parent(s): d40224e

still initial commit

Browse files
Files changed (1) hide show
  1. app.py +29 -4
app.py CHANGED
@@ -3,9 +3,10 @@ import cv2
3
  import numpy as np
4
  from datetime import datetime
5
 
6
- # ── 🛠️ 0. HUGGINGFACE HUB COMPATIBILITY PATCH ──────────────────────────────
7
- # Fixes: ImportError: cannot import name 'HfFolder' from 'huggingface_hub'
8
- # Hugging Face Hub >= 0.27 removed HfFolder, but Gradio 4.44.0 still expects it.
 
9
  import huggingface_hub
10
  if not hasattr(huggingface_hub, "HfFolder"):
11
  class MockHfFolder:
@@ -14,6 +15,29 @@ if not hasattr(huggingface_hub, "HfFolder"):
14
  return os.environ.get("HF_TOKEN")
15
  huggingface_hub.HfFolder = MockHfFolder
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  import gradio as gr
18
  import modal
19
 
@@ -174,4 +198,5 @@ with gr.Blocks(title="⛏️ Minecraft Spatial Voxel Filter") as demo:
174
  )
175
 
176
  if __name__ == "__main__":
177
- demo.launch()
 
 
3
  import numpy as np
4
  from datetime import datetime
5
 
6
+ # ── 🛠️ 0. THE "DUCT TAPE" MONKEYPATCHES ──────────────────────────────────────
7
+ # Python 3.13 + Gradio 4.44.0 + Hugging Face Spaces requires these overrides.
8
+
9
+ # Patch A: Hugging Face Hub (Fixes: ImportError: cannot import name 'HfFolder')
10
  import huggingface_hub
11
  if not hasattr(huggingface_hub, "HfFolder"):
12
  class MockHfFolder:
 
15
  return os.environ.get("HF_TOKEN")
16
  huggingface_hub.HfFolder = MockHfFolder
17
 
18
+ # Patch B: Gradio Client Schema Parser (Fixes: TypeError: argument of type 'bool' is not iterable)
19
+ try:
20
+ import gradio_client.utils
21
+
22
+ if hasattr(gradio_client.utils, "get_type"):
23
+ old_get_type = gradio_client.utils.get_type
24
+ def patched_get_type(schema):
25
+ if isinstance(schema, bool):
26
+ return "Any"
27
+ return old_get_type(schema)
28
+ gradio_client.utils.get_type = patched_get_type
29
+
30
+ if hasattr(gradio_client.utils, "_json_schema_to_python_type"):
31
+ old_internal_parser = gradio_client.utils._json_schema_to_python_type
32
+ def patched_internal_parser(schema, defs=None):
33
+ if isinstance(schema, bool):
34
+ return "Any"
35
+ return old_internal_parser(schema, defs)
36
+ gradio_client.utils._json_schema_to_python_type = patched_internal_parser
37
+ except Exception:
38
+ pass
39
+ # ─────────────────────────────────────────────────────────────────────────────
40
+
41
  import gradio as gr
42
  import modal
43
 
 
198
  )
199
 
200
  if __name__ == "__main__":
201
+ # Bound to 0.0.0.0 to bypass Hugging Face Spaces localhost proxy issues
202
+ demo.launch(server_name="0.0.0.0", server_port=7860)