ZhiyuanthePony commited on
Commit
9c76928
·
1 Parent(s): 4a69847
Files changed (2) hide show
  1. app.py +18 -1
  2. setup.sh +11 -0
app.py CHANGED
@@ -1,4 +1,21 @@
1
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import torch
3
  import gradio as gr
4
  from typing import *
@@ -10,7 +27,7 @@ from triplaneturbo_executable.utils.mesh_exporter import export_obj
10
 
11
  # Initialize global variables
12
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
13
- ADAPTER_PATH = "/home/user/app/pretrained/triplane_turbo_sd_v1.pth"
14
  PIPELINE = None # Will hold our pipeline instance
15
  OBJ_FILE_QUEUE = deque(maxlen=100) # Queue to store OBJ file paths
16
 
 
1
  import os
2
+ import subprocess
3
+ import sys
4
+
5
+ # Check if setup has been run
6
+ setup_marker = ".setup_complete"
7
+ if not os.path.exists(setup_marker):
8
+ print("First run detected, installing dependencies...")
9
+ try:
10
+ subprocess.check_call(["bash", "setup.sh"])
11
+ # Create marker file to indicate setup is complete
12
+ with open(setup_marker, "w") as f:
13
+ f.write("Setup completed")
14
+ print("Setup completed successfully!")
15
+ except subprocess.CalledProcessError as e:
16
+ print(f"Setup failed with error: {e}")
17
+ sys.exit(1)
18
+
19
  import torch
20
  import gradio as gr
21
  from typing import *
 
27
 
28
  # Initialize global variables
29
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
30
+ ADAPTER_PATH = "pretrained/triplane_turbo_sd_v1.pth" #"/home/user/app/pretrained/triplane_turbo_sd_v1.pth"
31
  PIPELINE = None # Will hold our pipeline instance
32
  OBJ_FILE_QUEUE = deque(maxlen=100) # Queue to store OBJ file paths
33
 
setup.sh ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ echo "Installing PyTorch with CUDA support..."
2
+ pip install torch==2.2.0+cu121 torchvision==0.17.0+cu121 torchaudio==2.2.0+cu121 \
3
+ --extra-index-url https://download.pytorch.org/whl/cu121
4
+
5
+ echo "Reinstalling NumPy with specific version..."
6
+ pip install --force-reinstall -v "numpy==1.25.2"
7
+
8
+ echo "Installing other requirements..."
9
+ pip install -r requirements.txt
10
+
11
+ echo "Setup completed successfully!"