Update app.py
Browse files
app.py
CHANGED
|
@@ -22,6 +22,33 @@
|
|
| 22 |
from huggingface_hub import hf_hub_download
|
| 23 |
import os
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
# Import utilities - CRITICAL: Use these functions, don't duplicate!
|
| 26 |
from utilities import (
|
| 27 |
segment_person_hq,
|
|
@@ -778,11 +805,11 @@ def main():
|
|
| 778 |
demo = create_interface()
|
| 779 |
|
| 780 |
print("Launching...")
|
| 781 |
-
# Fixed for
|
| 782 |
demo.queue().launch(
|
| 783 |
server_name="0.0.0.0",
|
| 784 |
server_port=7860,
|
| 785 |
-
share=
|
| 786 |
show_error=True,
|
| 787 |
debug=True
|
| 788 |
)
|
|
|
|
| 22 |
from huggingface_hub import hf_hub_download
|
| 23 |
import os
|
| 24 |
|
| 25 |
+
# ============================================================================ #
|
| 26 |
+
# CRITICAL: GRADIO SCHEMA VALIDATION FIX - MUST BE FIRST
|
| 27 |
+
# ============================================================================ #
|
| 28 |
+
try:
|
| 29 |
+
import gradio_client.utils as gc_utils
|
| 30 |
+
original_get_type = gc_utils.get_type
|
| 31 |
+
|
| 32 |
+
def patched_get_type(schema):
|
| 33 |
+
"""Fixed get_type function that handles boolean schemas properly"""
|
| 34 |
+
if not isinstance(schema, dict):
|
| 35 |
+
if isinstance(schema, bool):
|
| 36 |
+
return "boolean"
|
| 37 |
+
if isinstance(schema, str):
|
| 38 |
+
return "string"
|
| 39 |
+
if isinstance(schema, (int, float)):
|
| 40 |
+
return "number"
|
| 41 |
+
return "string" # fallback
|
| 42 |
+
|
| 43 |
+
# If it's a dict, use original function
|
| 44 |
+
return original_get_type(schema)
|
| 45 |
+
|
| 46 |
+
gc_utils.get_type = patched_get_type
|
| 47 |
+
print("✅ CRITICAL: Gradio schema patch applied successfully!")
|
| 48 |
+
|
| 49 |
+
except (ImportError, AttributeError) as e:
|
| 50 |
+
print(f"❌ CRITICAL: Gradio patch failed: {e}")
|
| 51 |
+
|
| 52 |
# Import utilities - CRITICAL: Use these functions, don't duplicate!
|
| 53 |
from utilities import (
|
| 54 |
segment_person_hq,
|
|
|
|
| 805 |
demo = create_interface()
|
| 806 |
|
| 807 |
print("Launching...")
|
| 808 |
+
# Fixed for HF Spaces - share=True is required when localhost not accessible
|
| 809 |
demo.queue().launch(
|
| 810 |
server_name="0.0.0.0",
|
| 811 |
server_port=7860,
|
| 812 |
+
share=True, # Required for HF Spaces
|
| 813 |
show_error=True,
|
| 814 |
debug=True
|
| 815 |
)
|