bulatko commited on
Commit
cdf98d2
·
1 Parent(s): 3509f56

Disable SSR via env var GRADIO_SSR_MODE=false

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -2,6 +2,9 @@ import os
2
  import sys
3
  import subprocess
4
 
 
 
 
5
  # Check if we're running on HF Spaces with Zero GPU
6
  # HF Spaces sets SPACE_ID environment variable
7
  IS_HF_SPACE = bool(os.environ.get("SPACE_ID"))
@@ -25,12 +28,21 @@ import gradio as gr
25
 
26
 
27
  def _launch():
28
- # Add CropFormer to PYTHONPATH (needed when using prebuilt detectron2)
 
29
  repo_root = os.path.dirname(os.path.abspath(__file__))
30
- cropformer_path = os.path.join(repo_root, "MaskClustering/third_party/detectron2/projects/CropFormer")
 
 
 
31
  if cropformer_path not in sys.path:
32
  sys.path.insert(0, cropformer_path)
33
 
 
 
 
 
 
34
  # Set environment variables for Zero GPU optimization
35
  if IS_ZERO_GPU:
36
  print("🚀 Detected Zero GPU environment, optimizing settings...")
 
2
  import sys
3
  import subprocess
4
 
5
+ # Disable SSR mode - it causes issues with Zero GPU
6
+ os.environ["GRADIO_SSR_MODE"] = "false"
7
+
8
  # Check if we're running on HF Spaces with Zero GPU
9
  # HF Spaces sets SPACE_ID environment variable
10
  IS_HF_SPACE = bool(os.environ.get("SPACE_ID"))
 
28
 
29
 
30
  def _launch():
31
+ # Add CropFormer and DeepLab to PYTHONPATH (needed when using prebuilt detectron2)
32
+ # Prebuilt detectron2 doesn't include projects/, so we need to add them manually
33
  repo_root = os.path.dirname(os.path.abspath(__file__))
34
+ projects_root = os.path.join(repo_root, "MaskClustering/third_party/detectron2/projects")
35
+
36
+ # Add CropFormer (main project we use)
37
+ cropformer_path = os.path.join(projects_root, "CropFormer")
38
  if cropformer_path not in sys.path:
39
  sys.path.insert(0, cropformer_path)
40
 
41
+ # Add DeepLab (required by CropFormer for add_deeplab_config)
42
+ deeplab_path = os.path.join(projects_root, "DeepLab")
43
+ if deeplab_path not in sys.path:
44
+ sys.path.insert(0, deeplab_path)
45
+
46
  # Set environment variables for Zero GPU optimization
47
  if IS_ZERO_GPU:
48
  print("🚀 Detected Zero GPU environment, optimizing settings...")