Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -308,9 +308,10 @@ def _process(img: Image.Image, prompt: str | BoundingBox | None, bg_prompt: str
|
|
308 |
try:
|
309 |
if torch.cuda.is_available():
|
310 |
current_device = torch.cuda.current_device()
|
311 |
-
torch.cuda.
|
|
|
312 |
except Exception as e:
|
313 |
-
print(f"CUDA memory
|
314 |
|
315 |
with torch.cuda.amp.autocast(enabled=torch.cuda.is_available()):
|
316 |
mask, bbox, time_log = _gpu_process(img, prompt)
|
@@ -324,7 +325,9 @@ def _process(img: Image.Image, prompt: str | BoundingBox | None, bg_prompt: str
|
|
324 |
|
325 |
clear_memory()
|
326 |
|
327 |
-
|
|
|
|
|
328 |
except Exception as e:
|
329 |
clear_memory()
|
330 |
print(f"Processing error: {str(e)}")
|
@@ -682,10 +685,10 @@ gr.HTML("""
|
|
682 |
</div>
|
683 |
</div>
|
684 |
""")
|
|
|
685 |
demo.launch(
|
686 |
server_name="0.0.0.0",
|
687 |
server_port=7860,
|
688 |
-
share=
|
689 |
-
max_threads=2
|
690 |
-
allowed_paths=[examples_path] # ์์ ๋ ์์ ๊ฒฝ๋ก ์ฌ์ฉ
|
691 |
)
|
|
|
308 |
try:
|
309 |
if torch.cuda.is_available():
|
310 |
current_device = torch.cuda.current_device()
|
311 |
+
with torch.cuda.device(current_device):
|
312 |
+
torch.cuda.empty_cache()
|
313 |
except Exception as e:
|
314 |
+
print(f"CUDA memory management failed: {e}")
|
315 |
|
316 |
with torch.cuda.amp.autocast(enabled=torch.cuda.is_available()):
|
317 |
mask, bbox, time_log = _gpu_process(img, prompt)
|
|
|
325 |
|
326 |
clear_memory()
|
327 |
|
328 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp:
|
329 |
+
combined.save(temp.name)
|
330 |
+
return (img, combined, masked_alpha), gr.DownloadButton(value=temp.name, interactive=True)
|
331 |
except Exception as e:
|
332 |
clear_memory()
|
333 |
print(f"Processing error: {str(e)}")
|
|
|
685 |
</div>
|
686 |
</div>
|
687 |
""")
|
688 |
+
demo.queue(max_size=10) # ํ ํฌ๊ธฐ ์ ํ
|
689 |
demo.launch(
|
690 |
server_name="0.0.0.0",
|
691 |
server_port=7860,
|
692 |
+
share=False,
|
693 |
+
max_threads=2 # ์ค๋ ๋ ์ ์ ํ
|
|
|
694 |
)
|