ArmanRV commited on
Commit
74cc200
·
verified ·
1 Parent(s): 9e832a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -6
app.py CHANGED
@@ -8,21 +8,42 @@ import gradio as gr
8
  from PIL import Image
9
 
10
  # =========================
11
- # FIX: gradio 4.24 / gradio_client boolean schema crash in /api_info
12
  # =========================
13
  try:
14
  import gradio_client.utils as gcu
15
 
 
16
  _orig_get_type = gcu.get_type
17
 
18
  def _get_type_patched(schema):
19
- # JSON Schema allows boolean schemas (true/false). gradio_client 0.x may crash on bool.
20
  if isinstance(schema, bool):
21
  return "any"
22
  return _orig_get_type(schema)
23
 
24
  gcu.get_type = _get_type_patched
25
- print("Patched gradio_client.utils.get_type for boolean schemas", flush=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  except Exception as _e:
27
  print("gradio_client patch skipped:", repr(_e), flush=True)
28
 
@@ -462,10 +483,9 @@ with gr.Blocks(title="Virtual Try-On Rendez-vous", css=CUSTOM_CSS) as demo:
462
  fn=tryon_ui,
463
  inputs=[person, selected_garment_state],
464
  outputs=[out, status],
465
- concurrency_limit=1, # ✅ правильный лимит в gradio 4.x
466
  )
467
 
468
- # ✅ Gradio 4.x: no concurrency_count here
469
  demo.queue(max_size=20)
470
 
471
  if __name__ == "__main__":
@@ -476,5 +496,5 @@ if __name__ == "__main__":
476
  auth=APP_AUTH,
477
  max_threads=4,
478
  show_error=True,
479
- show_api=False, # ✅ главное: не дергаем /api_info (там у тебя падало)
480
  )
 
8
  from PIL import Image
9
 
10
  # =========================
11
+ # FIX: gradio 4.24 / gradio_client crashes on boolean JSON Schemas in /api_info
12
  # =========================
13
  try:
14
  import gradio_client.utils as gcu
15
 
16
+ # Patch get_type(bool) -> "any"
17
  _orig_get_type = gcu.get_type
18
 
19
  def _get_type_patched(schema):
 
20
  if isinstance(schema, bool):
21
  return "any"
22
  return _orig_get_type(schema)
23
 
24
  gcu.get_type = _get_type_patched
25
+
26
+ # Patch get_desc(bool) -> ""
27
+ _orig_get_desc = gcu.get_desc
28
+
29
+ def _get_desc_patched(schema):
30
+ if isinstance(schema, bool):
31
+ return ""
32
+ return _orig_get_desc(schema)
33
+
34
+ gcu.get_desc = _get_desc_patched
35
+
36
+ # Patch _json_schema_to_python_type(bool) -> "any"
37
+ _orig_json2py = gcu._json_schema_to_python_type
38
+
39
+ def _json_schema_to_python_type_patched(schema, defs=None):
40
+ if isinstance(schema, bool):
41
+ return "any"
42
+ return _orig_json2py(schema, defs)
43
+
44
+ gcu._json_schema_to_python_type = _json_schema_to_python_type_patched
45
+
46
+ print("Patched gradio_client.utils for boolean JSON Schemas (/api_info)", flush=True)
47
  except Exception as _e:
48
  print("gradio_client patch skipped:", repr(_e), flush=True)
49
 
 
483
  fn=tryon_ui,
484
  inputs=[person, selected_garment_state],
485
  outputs=[out, status],
486
+ concurrency_limit=1,
487
  )
488
 
 
489
  demo.queue(max_size=20)
490
 
491
  if __name__ == "__main__":
 
496
  auth=APP_AUTH,
497
  max_threads=4,
498
  show_error=True,
499
+ show_api=False,
500
  )