Spaces:
Running
on
T4
Running
on
T4
Upload gradio_app.py
Browse files- gradio_app.py +0 -50
gradio_app.py
CHANGED
@@ -43,35 +43,6 @@ if True:
|
|
43 |
subprocess.run(shlex.split("pip install custom_rasterizer-0.1-cp310-cp310-linux_x86_64.whl"), check=True)
|
44 |
|
45 |
|
46 |
-
def get_example_img_list():
|
47 |
-
print('Loading example img list ...')
|
48 |
-
return sorted(glob('./assets/example_images/**/*.png', recursive=True))
|
49 |
-
|
50 |
-
|
51 |
-
def get_example_txt_list():
|
52 |
-
print('Loading example txt list ...')
|
53 |
-
txt_list = list()
|
54 |
-
for line in open('./assets/example_prompts.txt', encoding='utf-8'):
|
55 |
-
txt_list.append(line.strip())
|
56 |
-
return txt_list
|
57 |
-
|
58 |
-
|
59 |
-
def get_example_mv_list():
|
60 |
-
print('Loading example mv list ...')
|
61 |
-
mv_list = list()
|
62 |
-
root = './assets/example_mv_images'
|
63 |
-
for mv_dir in os.listdir(root):
|
64 |
-
view_list = []
|
65 |
-
for view in ['front', 'back', 'left', 'right']:
|
66 |
-
path = os.path.join(root, mv_dir, f'{view}.png')
|
67 |
-
if os.path.exists(path):
|
68 |
-
view_list.append(path)
|
69 |
-
else:
|
70 |
-
view_list.append(None)
|
71 |
-
mv_list.append(view_list)
|
72 |
-
return mv_list
|
73 |
-
|
74 |
-
|
75 |
def gen_save_folder(max_size=200):
|
76 |
os.makedirs(SAVE_DIR, exist_ok=True)
|
77 |
|
@@ -144,8 +115,6 @@ def build_model_viewer_html(save_folder, height=660, width=790, textured=False):
|
|
144 |
|
145 |
@spaces.GPU(duration=40)
|
146 |
def _gen_shape(
|
147 |
-
caption=None,
|
148 |
-
image=None,
|
149 |
mv_image_front=None,
|
150 |
mv_image_back=None,
|
151 |
mv_image_left=None,
|
@@ -158,8 +127,6 @@ def _gen_shape(
|
|
158 |
num_chunks=200000,
|
159 |
randomize_seed: bool = False,
|
160 |
):
|
161 |
-
if not MV_MODE and image is None and caption is None:
|
162 |
-
raise gr.Error("Please provide either a caption or an image.")
|
163 |
if MV_MODE:
|
164 |
if mv_image_front is None and mv_image_back is None and mv_image_left is None and mv_image_right is None:
|
165 |
raise gr.Error("Please provide at least one view image.")
|
@@ -176,7 +143,6 @@ def _gen_shape(
|
|
176 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
177 |
|
178 |
octree_resolution = int(octree_resolution)
|
179 |
-
if caption: print('prompt is', caption)
|
180 |
save_folder = gen_save_folder()
|
181 |
stats = {
|
182 |
'model': {
|
@@ -184,7 +150,6 @@ def _gen_shape(
|
|
184 |
'texgen': f'{args.texgen_model_path}',
|
185 |
},
|
186 |
'params': {
|
187 |
-
'caption': caption,
|
188 |
'steps': steps,
|
189 |
'guidance_scale': guidance_scale,
|
190 |
'seed': seed,
|
@@ -251,8 +216,6 @@ def _gen_shape(
|
|
251 |
|
252 |
@spaces.GPU(duration=90)
|
253 |
def generation_all(
|
254 |
-
caption=None,
|
255 |
-
image=None,
|
256 |
mv_image_front=None,
|
257 |
mv_image_back=None,
|
258 |
mv_image_left=None,
|
@@ -267,8 +230,6 @@ def generation_all(
|
|
267 |
):
|
268 |
start_time_0 = time.time()
|
269 |
mesh, image, save_folder, stats, seed = _gen_shape(
|
270 |
-
caption,
|
271 |
-
image,
|
272 |
mv_image_front=mv_image_front,
|
273 |
mv_image_back=mv_image_back,
|
274 |
mv_image_left=mv_image_left,
|
@@ -316,8 +277,6 @@ def generation_all(
|
|
316 |
|
317 |
@spaces.GPU(duration=40)
|
318 |
def shape_generation(
|
319 |
-
caption=None,
|
320 |
-
image=None,
|
321 |
mv_image_front=None,
|
322 |
mv_image_back=None,
|
323 |
mv_image_left=None,
|
@@ -332,8 +291,6 @@ def shape_generation(
|
|
332 |
):
|
333 |
start_time_0 = time.time()
|
334 |
mesh, image, save_folder, stats, seed = _gen_shape(
|
335 |
-
caption,
|
336 |
-
image,
|
337 |
mv_image_front=mv_image_front,
|
338 |
mv_image_back=mv_image_back,
|
339 |
mv_image_left=mv_image_left,
|
@@ -469,8 +426,6 @@ def build_app():
|
|
469 |
btn.click(
|
470 |
shape_generation,
|
471 |
inputs=[
|
472 |
-
caption,
|
473 |
-
image,
|
474 |
mv_image_front,
|
475 |
mv_image_back,
|
476 |
mv_image_left,
|
@@ -496,8 +451,6 @@ def build_app():
|
|
496 |
btn_all.click(
|
497 |
generation_all,
|
498 |
inputs=[
|
499 |
-
caption,
|
500 |
-
image,
|
501 |
mv_image_front,
|
502 |
mv_image_back,
|
503 |
mv_image_left,
|
@@ -633,9 +586,6 @@ if __name__ == '__main__':
|
|
633 |
border-color: #e5e7eb; order-style: solid; border-width: 1px;'>
|
634 |
</div>
|
635 |
"""
|
636 |
-
example_is = get_example_img_list()
|
637 |
-
example_ts = get_example_txt_list()
|
638 |
-
example_mvs = get_example_mv_list()
|
639 |
|
640 |
SUPPORTED_FORMATS = ['glb', 'obj', 'ply', 'stl']
|
641 |
|
|
|
43 |
subprocess.run(shlex.split("pip install custom_rasterizer-0.1-cp310-cp310-linux_x86_64.whl"), check=True)
|
44 |
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
def gen_save_folder(max_size=200):
|
47 |
os.makedirs(SAVE_DIR, exist_ok=True)
|
48 |
|
|
|
115 |
|
116 |
@spaces.GPU(duration=40)
|
117 |
def _gen_shape(
|
|
|
|
|
118 |
mv_image_front=None,
|
119 |
mv_image_back=None,
|
120 |
mv_image_left=None,
|
|
|
127 |
num_chunks=200000,
|
128 |
randomize_seed: bool = False,
|
129 |
):
|
|
|
|
|
130 |
if MV_MODE:
|
131 |
if mv_image_front is None and mv_image_back is None and mv_image_left is None and mv_image_right is None:
|
132 |
raise gr.Error("Please provide at least one view image.")
|
|
|
143 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
144 |
|
145 |
octree_resolution = int(octree_resolution)
|
|
|
146 |
save_folder = gen_save_folder()
|
147 |
stats = {
|
148 |
'model': {
|
|
|
150 |
'texgen': f'{args.texgen_model_path}',
|
151 |
},
|
152 |
'params': {
|
|
|
153 |
'steps': steps,
|
154 |
'guidance_scale': guidance_scale,
|
155 |
'seed': seed,
|
|
|
216 |
|
217 |
@spaces.GPU(duration=90)
|
218 |
def generation_all(
|
|
|
|
|
219 |
mv_image_front=None,
|
220 |
mv_image_back=None,
|
221 |
mv_image_left=None,
|
|
|
230 |
):
|
231 |
start_time_0 = time.time()
|
232 |
mesh, image, save_folder, stats, seed = _gen_shape(
|
|
|
|
|
233 |
mv_image_front=mv_image_front,
|
234 |
mv_image_back=mv_image_back,
|
235 |
mv_image_left=mv_image_left,
|
|
|
277 |
|
278 |
@spaces.GPU(duration=40)
|
279 |
def shape_generation(
|
|
|
|
|
280 |
mv_image_front=None,
|
281 |
mv_image_back=None,
|
282 |
mv_image_left=None,
|
|
|
291 |
):
|
292 |
start_time_0 = time.time()
|
293 |
mesh, image, save_folder, stats, seed = _gen_shape(
|
|
|
|
|
294 |
mv_image_front=mv_image_front,
|
295 |
mv_image_back=mv_image_back,
|
296 |
mv_image_left=mv_image_left,
|
|
|
426 |
btn.click(
|
427 |
shape_generation,
|
428 |
inputs=[
|
|
|
|
|
429 |
mv_image_front,
|
430 |
mv_image_back,
|
431 |
mv_image_left,
|
|
|
451 |
btn_all.click(
|
452 |
generation_all,
|
453 |
inputs=[
|
|
|
|
|
454 |
mv_image_front,
|
455 |
mv_image_back,
|
456 |
mv_image_left,
|
|
|
586 |
border-color: #e5e7eb; order-style: solid; border-width: 1px;'>
|
587 |
</div>
|
588 |
"""
|
|
|
|
|
|
|
589 |
|
590 |
SUPPORTED_FORMATS = ['glb', 'obj', 'ply', 'stl']
|
591 |
|