Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
# Not ready to use yet
|
2 |
import spaces
|
3 |
-
import base64
|
4 |
import argparse
|
5 |
import numpy as np
|
6 |
import gradio as gr
|
@@ -96,7 +95,6 @@ def preprocess_image(image, background_choice, foreground_ratio, backgroud_color
|
|
96 |
return image.convert("RGB")
|
97 |
|
98 |
@spaces.GPU
|
99 |
-
|
100 |
def gen_image(input_image, seed, scale, step):
|
101 |
global pipeline, model, args
|
102 |
pipeline.set_seed(seed)
|
@@ -105,16 +103,9 @@ def gen_image(input_image, seed, scale, step):
|
|
105 |
stage2_images = rt_dict["stage2_images"]
|
106 |
np_imgs = np.concatenate(stage1_images, 1)
|
107 |
np_xyzs = np.concatenate(stage2_images, 1)
|
108 |
-
|
109 |
glb_path = generate3d(model, np_imgs, np_xyzs, args.device)
|
110 |
-
|
111 |
-
# Read the GLB file and encode it in base64
|
112 |
-
with open(glb_path, 'rb') as f:
|
113 |
-
glb_bytes = f.read()
|
114 |
-
encoded_glb = 'data:model/gltf-binary;base64,' + base64.b64encode(glb_bytes).decode('utf-8')
|
115 |
-
|
116 |
-
# Return images and the encoded GLB data
|
117 |
-
return Image.fromarray(np_imgs), Image.fromarray(np_xyzs), encoded_glb
|
118 |
|
119 |
|
120 |
parser = argparse.ArgumentParser()
|
|
|
1 |
# Not ready to use yet
|
2 |
import spaces
|
|
|
3 |
import argparse
|
4 |
import numpy as np
|
5 |
import gradio as gr
|
|
|
95 |
return image.convert("RGB")
|
96 |
|
97 |
@spaces.GPU
|
|
|
98 |
def gen_image(input_image, seed, scale, step):
|
99 |
global pipeline, model, args
|
100 |
pipeline.set_seed(seed)
|
|
|
103 |
stage2_images = rt_dict["stage2_images"]
|
104 |
np_imgs = np.concatenate(stage1_images, 1)
|
105 |
np_xyzs = np.concatenate(stage2_images, 1)
|
106 |
+
|
107 |
glb_path = generate3d(model, np_imgs, np_xyzs, args.device)
|
108 |
+
return Image.fromarray(np_imgs), Image.fromarray(np_xyzs), glb_path#, obj_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
|
111 |
parser = argparse.ArgumentParser()
|