ritianyu commited on
Commit
aeeec7b
·
1 Parent(s): 5d0d869
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -193,11 +193,8 @@ def _build_examples_rows(samples: list[dict[str, Optional[str]]]) -> list[list[O
193
  return rows
194
 
195
 
196
- def _prepare_output_dir(request: Optional[gr.Request]) -> Path:
197
- session_hash = "local"
198
- if request is not None and getattr(request, "session_hash", None):
199
- session_hash = str(request.session_hash)
200
- session_dir = OUTPUT_ROOT / session_hash
201
  session_dir.mkdir(parents=True, exist_ok=True)
202
  output_dir = session_dir / uuid.uuid4().hex
203
  output_dir.mkdir(parents=True, exist_ok=True)
@@ -229,7 +226,6 @@ def run_demo(
229
  fy_org: Optional[float],
230
  cx_org: Optional[float],
231
  cy_org: Optional[float],
232
- request: gr.Request,
233
  ):
234
  request_id = uuid.uuid4().hex[:8]
235
  try:
@@ -241,9 +237,8 @@ def run_demo(
241
  depth_path = depth_file if isinstance(depth_file, str) else depth_file.name
242
 
243
  image_shape = tuple(int(dim) for dim in image.shape) if image is not None else None
244
- session_hash = getattr(request, "session_hash", None) if request is not None else None
245
  Log.info(
246
- f"[{request_id}] run_demo start: session_hash={session_hash}, model_type={model_type}, "
247
  f"input_size={input_size}, output_resolution_mode={output_resolution_mode}, "
248
  f"upsample_ratio={upsample_ratio}, max_points_preview={max_points_preview}, "
249
  f"depth_path={depth_path}, image_shape={image_shape}"
@@ -263,7 +258,7 @@ def run_demo(
263
  cy_org=_none_if_invalid(cy_org),
264
  model_cache=MODEL_CACHE,
265
  )
266
- output_dir = _prepare_output_dir(request)
267
  glb_path = output_dir / "pointcloud.glb"
268
  ply_path = output_dir / "pointcloud.ply"
269
  depth_vis_path = output_dir / "depth_colorized.png"
@@ -432,6 +427,8 @@ if __name__ == "__main__":
432
  "server_name": server_name,
433
  "server_port": server_port,
434
  }
 
 
435
  if os.getenv("INFINIDEPTH_SHOW_ERROR", "0") == "1":
436
  launch_kwargs["show_error"] = True
437
  demo.launch(**launch_kwargs)
 
193
  return rows
194
 
195
 
196
+ def _prepare_output_dir() -> Path:
197
+ session_dir = OUTPUT_ROOT / "local"
 
 
 
198
  session_dir.mkdir(parents=True, exist_ok=True)
199
  output_dir = session_dir / uuid.uuid4().hex
200
  output_dir.mkdir(parents=True, exist_ok=True)
 
226
  fy_org: Optional[float],
227
  cx_org: Optional[float],
228
  cy_org: Optional[float],
 
229
  ):
230
  request_id = uuid.uuid4().hex[:8]
231
  try:
 
237
  depth_path = depth_file if isinstance(depth_file, str) else depth_file.name
238
 
239
  image_shape = tuple(int(dim) for dim in image.shape) if image is not None else None
 
240
  Log.info(
241
+ f"[{request_id}] run_demo start: model_type={model_type}, "
242
  f"input_size={input_size}, output_resolution_mode={output_resolution_mode}, "
243
  f"upsample_ratio={upsample_ratio}, max_points_preview={max_points_preview}, "
244
  f"depth_path={depth_path}, image_shape={image_shape}"
 
258
  cy_org=_none_if_invalid(cy_org),
259
  model_cache=MODEL_CACHE,
260
  )
261
+ output_dir = _prepare_output_dir()
262
  glb_path = output_dir / "pointcloud.glb"
263
  ply_path = output_dir / "pointcloud.ply"
264
  depth_vis_path = output_dir / "depth_colorized.png"
 
427
  "server_name": server_name,
428
  "server_port": server_port,
429
  }
430
+ if os.getenv("SPACE_ID"):
431
+ launch_kwargs["ssr_mode"] = False
432
  if os.getenv("INFINIDEPTH_SHOW_ERROR", "0") == "1":
433
  launch_kwargs["show_error"] = True
434
  demo.launch(**launch_kwargs)