Spaces:
Running
on
L40S
Running
on
L40S
Update app.py
Browse files
app.py
CHANGED
@@ -76,12 +76,14 @@ def initialize_models(device):
|
|
76 |
torch.cuda.empty_cache()
|
77 |
torch.backends.cuda.matmul.allow_tf32 = True
|
78 |
torch.backends.cudnn.benchmark = True
|
|
|
|
|
79 |
# 환경 변수 설정
|
80 |
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:512"
|
81 |
os.environ['SPCONV_ALGO'] = 'native'
|
82 |
os.environ['SPARSE_BACKEND'] = 'native'
|
83 |
-
os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
|
84 |
-
|
85 |
|
86 |
# Hugging Face 토큰 설정
|
87 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
@@ -208,6 +210,9 @@ def image_to_3d(trial_id: str, seed: int, randomize_seed: bool, ss_guidance_stre
|
|
208 |
image = Image.open(image_path)
|
209 |
print(f"Successfully loaded image with size: {image.size}")
|
210 |
|
|
|
|
|
|
|
211 |
|
212 |
outputs = g.trellis_pipeline.run(
|
213 |
image,
|
@@ -232,10 +237,16 @@ def image_to_3d(trial_id: str, seed: int, randomize_seed: bool, ss_guidance_stre
|
|
232 |
os.makedirs(os.path.dirname(video_path), exist_ok=True)
|
233 |
imageio.mimsave(video_path, video, fps=15)
|
234 |
state = pack_state(outputs['gaussian'][0], outputs['mesh'][0], new_trial_id)
|
|
|
|
|
|
|
|
|
235 |
return state, video_path
|
236 |
|
237 |
except Exception as e:
|
238 |
print(f"Error in image_to_3d: {str(e)}")
|
|
|
|
|
239 |
return None, None
|
240 |
|
241 |
|
|
|
76 |
torch.cuda.empty_cache()
|
77 |
torch.backends.cuda.matmul.allow_tf32 = True
|
78 |
torch.backends.cudnn.benchmark = True
|
79 |
+
|
80 |
+
|
81 |
# 환경 변수 설정
|
82 |
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:512"
|
83 |
os.environ['SPCONV_ALGO'] = 'native'
|
84 |
os.environ['SPARSE_BACKEND'] = 'native'
|
85 |
+
os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
|
86 |
+
os.environ['TORCH_USE_CUDA_DSA'] = '1'
|
87 |
|
88 |
# Hugging Face 토큰 설정
|
89 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
|
|
210 |
image = Image.open(image_path)
|
211 |
print(f"Successfully loaded image with size: {image.size}")
|
212 |
|
213 |
+
# GPU로 모델 이동
|
214 |
+
if not g.trellis_pipeline.device.type == "cuda":
|
215 |
+
g.trellis_pipeline = g.trellis_pipeline.to("cuda")
|
216 |
|
217 |
outputs = g.trellis_pipeline.run(
|
218 |
image,
|
|
|
237 |
os.makedirs(os.path.dirname(video_path), exist_ok=True)
|
238 |
imageio.mimsave(video_path, video, fps=15)
|
239 |
state = pack_state(outputs['gaussian'][0], outputs['mesh'][0], new_trial_id)
|
240 |
+
|
241 |
+
# CPU로 모델 되돌리기
|
242 |
+
g.trellis_pipeline = g.trellis_pipeline.to("cpu")
|
243 |
+
|
244 |
return state, video_path
|
245 |
|
246 |
except Exception as e:
|
247 |
print(f"Error in image_to_3d: {str(e)}")
|
248 |
+
if g.trellis_pipeline.device.type == "cuda":
|
249 |
+
g.trellis_pipeline = g.trellis_pipeline.to("cpu")
|
250 |
return None, None
|
251 |
|
252 |
|