Spaces:
Running on Zero
Running on Zero
fix
Browse files- README.md +1 -1
- app.py +17 -2
- requirements.txt +2 -2
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🧞
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 4.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
license: mit
|
|
|
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
license: mit
|
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import os
|
|
| 4 |
is_spaces = True if os.environ.get('SPACE_ID') else False
|
| 5 |
if is_spaces:
|
| 6 |
import spaces
|
| 7 |
-
from gradio_client import Client, handle_file
|
| 8 |
from huggingface_hub import snapshot_download, HfApi
|
| 9 |
import uuid
|
| 10 |
import shutil
|
|
@@ -34,6 +34,21 @@ mage_vl_client = None
|
|
| 34 |
caption_cache = {}
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# A Space configured for ZeroGPU must register at least one GPU function during
|
| 38 |
# startup. Captioning itself runs in the separate Mage-VL Space, so this probe is
|
| 39 |
# intentionally not placed around run_captioning (which would waste local quota
|
|
@@ -1178,4 +1193,4 @@ If you prefer command line, you can run our [training script]({training_script_u
|
|
| 1178 |
#demo.load(fn=swap_opacity, outputs=[main_ui], queue=False, concurrency_limit=50)
|
| 1179 |
if __name__ == "__main__":
|
| 1180 |
demo.queue()
|
| 1181 |
-
demo.launch(share=
|
|
|
|
| 4 |
is_spaces = True if os.environ.get('SPACE_ID') else False
|
| 5 |
if is_spaces:
|
| 6 |
import spaces
|
| 7 |
+
from gradio_client import Client, handle_file, utils as gradio_client_utils
|
| 8 |
from huggingface_hub import snapshot_download, HfApi
|
| 9 |
import uuid
|
| 10 |
import shutil
|
|
|
|
| 34 |
caption_cache = {}
|
| 35 |
|
| 36 |
|
| 37 |
+
# Gradio 4.x's API schema formatter assumes every JSON Schema node is a dict.
|
| 38 |
+
# Pydantic can legally emit a boolean node such as `additionalProperties: false`,
|
| 39 |
+
# which otherwise crashes the Space's root route before the UI is displayed.
|
| 40 |
+
_original_schema_to_python_type = gradio_client_utils._json_schema_to_python_type
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def _safe_schema_to_python_type(schema, defs):
|
| 44 |
+
if isinstance(schema, bool):
|
| 45 |
+
return "Any"
|
| 46 |
+
return _original_schema_to_python_type(schema, defs)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
gradio_client_utils._json_schema_to_python_type = _safe_schema_to_python_type
|
| 50 |
+
|
| 51 |
+
|
| 52 |
# A Space configured for ZeroGPU must register at least one GPU function during
|
| 53 |
# startup. Captioning itself runs in the separate Mage-VL Space, so this probe is
|
| 54 |
# intentionally not placed around run_captioning (which would waste local quota
|
|
|
|
| 1193 |
#demo.load(fn=swap_opacity, outputs=[main_ui], queue=False, concurrency_limit=50)
|
| 1194 |
if __name__ == "__main__":
|
| 1195 |
demo.queue()
|
| 1196 |
+
demo.launch(share=not is_spaces)
|
requirements.txt
CHANGED
|
@@ -2,6 +2,6 @@ autotrain-advanced
|
|
| 2 |
numpy==1.26.4
|
| 3 |
huggingface-hub==0.27.0
|
| 4 |
python-slugify
|
| 5 |
-
gradio
|
| 6 |
-
gradio_client
|
| 7 |
spaces
|
|
|
|
| 2 |
numpy==1.26.4
|
| 3 |
huggingface-hub==0.27.0
|
| 4 |
python-slugify
|
| 5 |
+
gradio==4.44.1
|
| 6 |
+
gradio_client==1.3.0
|
| 7 |
spaces
|