Commit
·
e0263b2
1
Parent(s):
81d5d11
Refactor gen_image function in app.py to create a temporary GLB file with a proper extension and return its path. This change enhances file management by ensuring the generated file is correctly handled and simplifies the cleanup process.
Browse files
app.py
CHANGED
@@ -108,13 +108,19 @@ def gen_image(input_image, seed, scale, step):
|
|
108 |
|
109 |
glb_path = generate3d(model, np_imgs, np_xyzs, args.device)
|
110 |
|
111 |
-
#
|
112 |
-
|
113 |
-
|
114 |
-
encoded_glb = 'data:model/gltf-binary;base64,' + base64.b64encode(glb_bytes).decode('utf-8')
|
115 |
|
116 |
-
#
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
|
120 |
parser = argparse.ArgumentParser()
|
@@ -243,4 +249,4 @@ with gr.Blocks() as demo:
|
|
243 |
inputs=inputs,
|
244 |
outputs=outputs,
|
245 |
)
|
246 |
-
demo.queue().launch()
|
|
|
108 |
|
109 |
glb_path = generate3d(model, np_imgs, np_xyzs, args.device)
|
110 |
|
111 |
+
# Create a temporary file with a proper name for the GLB data
|
112 |
+
import tempfile
|
113 |
+
import shutil
|
|
|
114 |
|
115 |
+
# Create a temporary file with a proper extension
|
116 |
+
temp_glb = tempfile.NamedTemporaryFile(suffix='.glb', delete=False)
|
117 |
+
temp_glb.close()
|
118 |
+
|
119 |
+
# Copy the generated GLB file to our temporary file
|
120 |
+
shutil.copy2(glb_path, temp_glb.name)
|
121 |
+
|
122 |
+
# Return images and the path to the temporary GLB file
|
123 |
+
return Image.fromarray(np_imgs), Image.fromarray(np_xyzs), temp_glb.name
|
124 |
|
125 |
|
126 |
parser = argparse.ArgumentParser()
|
|
|
249 |
inputs=inputs,
|
250 |
outputs=outputs,
|
251 |
)
|
252 |
+
demo.queue().launch()
|