Spaces:
Sleeping
Sleeping
manishw7 commited on
Commit ·
1172399
1
Parent(s): 39ef92c
Final: Stable Gradio 3.x revert
Browse files
README.md
CHANGED
|
@@ -16,8 +16,8 @@ tags:
|
|
| 16 |
datasets:
|
| 17 |
- c3rl/IIIT-INDIC-HW-WORDS-Hindi
|
| 18 |
sdk: gradio
|
| 19 |
-
sdk_version:
|
| 20 |
-
python_version:
|
| 21 |
app_file: app.py
|
| 22 |
pinned: true
|
| 23 |
---
|
|
|
|
| 16 |
datasets:
|
| 17 |
- c3rl/IIIT-INDIC-HW-WORDS-Hindi
|
| 18 |
sdk: gradio
|
| 19 |
+
sdk_version: 3.50.2
|
| 20 |
+
python_version: 3.10
|
| 21 |
app_file: app.py
|
| 22 |
pinned: true
|
| 23 |
---
|
app.py
CHANGED
|
@@ -1,25 +1,3 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import sys
|
| 3 |
-
|
| 4 |
-
# --- SURGICAL MONKEY-PATCH FOR GRADIO ---
|
| 5 |
-
# This fixes the exact internal function that crashes on 'bool' types
|
| 6 |
-
# without breaking the actual API endpoints.
|
| 7 |
-
try:
|
| 8 |
-
import gradio_client.utils
|
| 9 |
-
original_fn = gradio_client.utils.json_schema_to_python_type
|
| 10 |
-
|
| 11 |
-
def patched_json_schema_to_python_type(schema, *args, **kwargs):
|
| 12 |
-
# The bug happens when 'schema' is a boolean. We force it to be a dict or handle it.
|
| 13 |
-
if isinstance(schema, bool):
|
| 14 |
-
return "Any"
|
| 15 |
-
return original_fn(schema, *args, **kwargs)
|
| 16 |
-
|
| 17 |
-
gradio_client.utils.json_schema_to_python_type = patched_json_schema_to_python_type
|
| 18 |
-
print("System: Applied surgical monkey-patch for Gradio schema bug.")
|
| 19 |
-
except Exception as e:
|
| 20 |
-
print(f"System: Failed to apply surgical patch: {e}")
|
| 21 |
-
# ----------------------------------------
|
| 22 |
-
|
| 23 |
import gradio as gr
|
| 24 |
import torch
|
| 25 |
from PIL import Image
|
|
@@ -59,7 +37,7 @@ def predict(image):
|
|
| 59 |
except Exception as e:
|
| 60 |
return f"Error during inference: {str(e)}"
|
| 61 |
|
| 62 |
-
#
|
| 63 |
demo = gr.Interface(
|
| 64 |
fn=predict,
|
| 65 |
inputs=gr.Image(type="pil", label="Upload Handwritten Devanagari Word"),
|
|
@@ -70,5 +48,5 @@ demo = gr.Interface(
|
|
| 70 |
)
|
| 71 |
|
| 72 |
if __name__ == "__main__":
|
| 73 |
-
#
|
| 74 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
from PIL import Image
|
|
|
|
| 37 |
except Exception as e:
|
| 38 |
return f"Error during inference: {str(e)}"
|
| 39 |
|
| 40 |
+
# Classic Gradio 3.x Interface
|
| 41 |
demo = gr.Interface(
|
| 42 |
fn=predict,
|
| 43 |
inputs=gr.Image(type="pil", label="Upload Handwritten Devanagari Word"),
|
|
|
|
| 48 |
)
|
| 49 |
|
| 50 |
if __name__ == "__main__":
|
| 51 |
+
# Required settings for Gradio 3.x on HF Spaces
|
| 52 |
+
demo.launch(server_name="0.0.0.0")
|