Commit
·
57a43ce
1
Parent(s):
65f401b
Refactor gen_image function in app.py to use a temporary file for GLB data instead of base64 encoding. This change improves file handling and returns the path to the temporary GLB file.
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()
|
|
|
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()
|