Spaces:
Runtime error
Runtime error
Automatically delete after 10 minutes.
Browse files
app.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
import torch
|
2 |
from meshgpt_pytorch import (
|
3 |
MeshTransformer,
|
4 |
mesh_render
|
5 |
)
|
6 |
import igl
|
7 |
-
|
8 |
import gradio as gr
|
9 |
-
import numpy as np
|
10 |
import tempfile
|
|
|
|
|
|
|
11 |
|
12 |
transformer = MeshTransformer.from_pretrained("MarcusLoren/MeshGPT-preview")
|
13 |
|
@@ -20,6 +20,11 @@ def save_as_obj(file_path):
|
|
20 |
return file_path
|
21 |
|
22 |
|
|
|
|
|
|
|
|
|
|
|
23 |
def predict(text, num_input, num_temp):
|
24 |
transformer.eval()
|
25 |
labels = [label.strip() for label in text.split(',')]
|
@@ -32,7 +37,10 @@ def predict(text, num_input, num_temp):
|
|
32 |
|
33 |
with tempfile.NamedTemporaryFile(suffix=".obj", delete=False) as temp_file:
|
34 |
mesh_render.save_rendering(temp_file.name, output)
|
35 |
-
|
|
|
|
|
|
|
36 |
|
37 |
gradio_app = gr.Interface(
|
38 |
predict,
|
|
|
|
|
1 |
from meshgpt_pytorch import (
|
2 |
MeshTransformer,
|
3 |
mesh_render
|
4 |
)
|
5 |
import igl
|
|
|
6 |
import gradio as gr
|
|
|
7 |
import tempfile
|
8 |
+
import os
|
9 |
+
import threading
|
10 |
+
import time
|
11 |
|
12 |
transformer = MeshTransformer.from_pretrained("MarcusLoren/MeshGPT-preview")
|
13 |
|
|
|
20 |
return file_path
|
21 |
|
22 |
|
23 |
+
def delete_file_after_ten_minutes(filename):
|
24 |
+
time.sleep(600) # Wait for 10 minutes
|
25 |
+
os.remove(filename)
|
26 |
+
|
27 |
+
|
28 |
def predict(text, num_input, num_temp):
|
29 |
transformer.eval()
|
30 |
labels = [label.strip() for label in text.split(',')]
|
|
|
37 |
|
38 |
with tempfile.NamedTemporaryFile(suffix=".obj", delete=False) as temp_file:
|
39 |
mesh_render.save_rendering(temp_file.name, output)
|
40 |
+
result = save_as_obj(temp_file.name)
|
41 |
+
threading.Thread(target=delete_file_after_ten_minutes, args=(temp_file.name,)).start()
|
42 |
+
|
43 |
+
return result
|
44 |
|
45 |
gradio_app = gr.Interface(
|
46 |
predict,
|