ilhamdev commited on
Commit
f1aafc7
·
verified ·
1 Parent(s): f751ede

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -2
app.py CHANGED
@@ -1,3 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import torch
2
  from PIL import Image
3
  from RealESRGAN import RealESRGAN
@@ -82,5 +102,6 @@ with gr.Blocks() as demo:
82
 
83
  gr.Markdown(article)
84
 
85
- # server_name="0.0.0.0" adalah konfigurasi resmi yang diizinkan Hugging Face Spaces
86
- demo.queue().launch(server_name="0.0.0.0", server_port=7860, show_error=True)
 
 
1
+ # --- MONKEY PATCH: MENAMBAL BUG INTERNAL GRADIO_CLIENT ---
2
+ import gradio_client.utils
3
+
4
+ if hasattr(gradio_client.utils, 'get_type'):
5
+ _original_get_type = gradio_client.utils.get_type
6
+ def _patched_get_type(schema):
7
+ if isinstance(schema, bool):
8
+ return "bool"
9
+ return _original_get_type(schema)
10
+ gradio_client.utils.get_type = _patched_get_type
11
+
12
+ if hasattr(gradio_client.utils, '_json_schema_to_python_type'):
13
+ _original_json_schema = gradio_client.utils._json_schema_to_python_type
14
+ def _patched_json_schema(schema, defs=None):
15
+ if isinstance(schema, bool):
16
+ return "bool"
17
+ return _original_json_schema(schema, defs)
18
+ gradio_client.utils._json_schema_to_python_type = _patched_json_schema
19
+ # ---------------------------------------------------------
20
+
21
  import torch
22
  from PIL import Image
23
  from RealESRGAN import RealESRGAN
 
102
 
103
  gr.Markdown(article)
104
 
105
+ # PENTING: Jangan gunakan server_name/server_port manual di Hugging Face Spaces.
106
+ # Biarkan Spaces mengaturnya secara otomatis untuk menghindari error 'localhost not accessible'.
107
+ demo.queue().launch(show_error=True)