shiveshnavin commited on
Commit
7e084b2
·
1 Parent(s): 55107ff
Files changed (1) hide show
  1. app.py +25 -12
app.py CHANGED
@@ -46,14 +46,12 @@ def _download_image(url: str, dst_dir: Path) -> Path:
46
 
47
 
48
  def _ensure_image(path: Path) -> Path:
49
- # Simple open-validate cycle (also normalizes/transcodes weird formats)
50
  with Image.open(path) as im:
51
- im.verify() # quick integrity check
52
  return path
53
 
54
 
55
  def _pick_output(candidates: List[Path]) -> Optional[Path]:
56
- """Prefer *_final.mp4 > *_vfx.mp4 > *_raw.mp4 > any .mp4 > any .gif."""
57
  if not candidates:
58
  return None
59
  prefer = [
@@ -126,15 +124,30 @@ def run_glitch(
126
  except subprocess.CalledProcessError as e:
127
  raise gr.Error(f"glitch.py failed: {e}")
128
 
129
- if not out_path.exists():
130
- cands = list(tdir.glob("**/*.mp4")) + list(tdir.glob("**/*.gif"))
131
- picked = _pick_output(cands)
132
- if not picked:
133
- tree = "\n".join(str(p) for p in tdir.rglob("*"))
134
- raise gr.Error("Output file not produced by glitch.py (no .mp4/.gif found). Files:\n" + tree)
135
- out_path = picked
136
-
137
- return str(out_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
 
140
  # --- Gradio UI ---
 
46
 
47
 
48
  def _ensure_image(path: Path) -> Path:
 
49
  with Image.open(path) as im:
50
+ im.verify()
51
  return path
52
 
53
 
54
  def _pick_output(candidates: List[Path]) -> Optional[Path]:
 
55
  if not candidates:
56
  return None
57
  prefer = [
 
124
  except subprocess.CalledProcessError as e:
125
  raise gr.Error(f"glitch.py failed: {e}")
126
 
127
+ # Look for output in multiple possible directories
128
+ search_roots = {tdir}
129
+ if src_path is not None:
130
+ search_roots.add(src_path.parent)
131
+
132
+ cands: List[Path] = []
133
+ for root in search_roots:
134
+ cands.extend(root.glob("*.mp4"))
135
+ cands.extend(root.glob("*.gif"))
136
+ cands.extend(root.rglob("*_final.mp4"))
137
+ cands.extend(root.rglob("*_vfx.mp4"))
138
+ cands.extend(root.rglob("*_raw.mp4"))
139
+
140
+ picked = _pick_output(list(set(cands)))
141
+ if not picked:
142
+ tree_lines = []
143
+ for root in list(search_roots):
144
+ for p in root.rglob("*"):
145
+ tree_lines.append(str(p))
146
+ if len(tree_lines) > 2000:
147
+ break
148
+ raise gr.Error("Output file not produced by glitch.py. Files scanned:\n" + "\n".join(tree_lines))
149
+
150
+ return str(picked)
151
 
152
 
153
  # --- Gradio UI ---