mqye commited on
Commit
e310aeb
Β·
1 Parent(s): 0eef6bb

Deploy MODUS 3-tab any-to-any demo (ZeroGPU)

Browse files
Files changed (2) hide show
  1. app.py +13 -0
  2. requirements.txt +2 -0
app.py CHANGED
@@ -21,6 +21,19 @@ try:
21
  except Exception as _e:
22
  print(f"[app] torch import failed: {_e}", flush=True)
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  # ── Install the MODUS backend from the (private) GitHub repo at startup ──────────
25
  # Single source of truth: this Space only carries app.py + fourm/ + test_images/;
26
  # the demo/inference code (demo_modus, any2any, modeling, data, core, conf, ...)
 
21
  except Exception as _e:
22
  print(f"[app] torch import failed: {_e}", flush=True)
23
 
24
+ # Teach PIL to decode in-the-wild formats (AVIF, iPhone HEIC). gradio opens each
25
+ # uploaded file with PIL.Image.open before it reaches our code, so registering
26
+ # these openers here (import-time) is what lets those uploads work at all.
27
+ try:
28
+ import pillow_avif # noqa: F401 (registers the AVIF opener on import)
29
+ except Exception as _e:
30
+ print(f"[app] pillow-avif-plugin unavailable: {_e}", flush=True)
31
+ try:
32
+ from pillow_heif import register_heif_opener
33
+ register_heif_opener()
34
+ except Exception as _e:
35
+ print(f"[app] pillow-heif unavailable: {_e}", flush=True)
36
+
37
  # ── Install the MODUS backend from the (private) GitHub repo at startup ──────────
38
  # Single source of truth: this Space only carries app.py + fourm/ + test_images/;
39
  # the demo/inference code (demo_modus, any2any, modeling, data, core, conf, ...)
requirements.txt CHANGED
@@ -18,6 +18,8 @@ diffusers==0.20.0 # diffusers_compat.py shims this for fourm
18
  # --- numerics / io / cv ---
19
  numpy==1.26.4
20
  pillow==10.4.0
 
 
21
  matplotlib==3.9.2
22
  opencv-python-headless==4.11.0.86
23
  pyarrow==17.0.0
 
18
  # --- numerics / io / cv ---
19
  numpy==1.26.4
20
  pillow==10.4.0
21
+ pillow-avif-plugin==1.4.6 # decode in-the-wild AVIF uploads
22
+ pillow-heif==0.18.0 # decode iPhone HEIC uploads
23
  matplotlib==3.9.2
24
  opencv-python-headless==4.11.0.86
25
  pyarrow==17.0.0