Spaces:
Runtime error
Runtime error
Use temp file.
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import igl
|
|
7 |
|
8 |
import gradio as gr
|
9 |
import numpy as np
|
|
|
10 |
|
11 |
transformer = MeshTransformer.from_pretrained("MarcusLoren/MeshGPT-preview")
|
12 |
|
@@ -18,6 +19,7 @@ def save_as_obj(file_path):
|
|
18 |
igl.write_triangle_mesh(file_path, v, f)
|
19 |
return file_path
|
20 |
|
|
|
21 |
def predict(text, num_input, num_temp):
|
22 |
transformer.eval()
|
23 |
labels = [label.strip() for label in text.split(',')]
|
@@ -27,9 +29,10 @@ def predict(text, num_input, num_temp):
|
|
27 |
output.append((transformer.generate(texts = [label ] * num_input, temperature = num_temp)))
|
28 |
else:
|
29 |
output.append((transformer.generate(texts = labels , temperature = num_temp)))
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
33 |
|
34 |
gradio_app = gr.Interface(
|
35 |
predict,
|
|
|
7 |
|
8 |
import gradio as gr
|
9 |
import numpy as np
|
10 |
+
import tempfile
|
11 |
|
12 |
transformer = MeshTransformer.from_pretrained("MarcusLoren/MeshGPT-preview")
|
13 |
|
|
|
19 |
igl.write_triangle_mesh(file_path, v, f)
|
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(',')]
|
|
|
29 |
output.append((transformer.generate(texts = [label ] * num_input, temperature = num_temp)))
|
30 |
else:
|
31 |
output.append((transformer.generate(texts = labels , temperature = num_temp)))
|
32 |
+
|
33 |
+
with tempfile.NamedTemporaryFile(suffix=".obj", delete=False) as temp_file:
|
34 |
+
mesh_render.save_rendering(temp_file.name, output)
|
35 |
+
return save_as_obj(temp_file.name)
|
36 |
|
37 |
gradio_app = gr.Interface(
|
38 |
predict,
|