Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -210,43 +210,37 @@ def image_to_3d(trial_id: str, seed: int, randomize_seed: bool, ss_guidance_stre
|
|
210 |
image = Image.open(image_path)
|
211 |
print(f"Successfully loaded image with size: {image.size}")
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
"cfg_strength": slat_guidance_strength,
|
229 |
-
},
|
230 |
-
)
|
231 |
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
return state, video_path
|
245 |
|
246 |
except Exception as e:
|
247 |
print(f"Error in image_to_3d: {str(e)}")
|
248 |
-
|
249 |
-
g.trellis_pipeline = g.trellis_pipeline.to("cpu")
|
250 |
return None, None
|
251 |
|
252 |
|
@@ -498,8 +492,7 @@ if __name__ == "__main__":
|
|
498 |
allowed_paths=[PERSISTENT_DIR, TMP_DIR],
|
499 |
server_name="0.0.0.0",
|
500 |
server_port=7860,
|
501 |
-
show_error=True
|
502 |
-
share=True
|
503 |
)
|
504 |
|
505 |
except Exception as e:
|
|
|
210 |
image = Image.open(image_path)
|
211 |
print(f"Successfully loaded image with size: {image.size}")
|
212 |
|
213 |
+
with torch.cuda.device(0):
|
214 |
+
outputs = g.trellis_pipeline.run(
|
215 |
+
image,
|
216 |
+
seed=seed,
|
217 |
+
formats=["gaussian", "mesh"],
|
218 |
+
preprocess_image=False,
|
219 |
+
sparse_structure_sampler_params={
|
220 |
+
"steps": ss_sampling_steps,
|
221 |
+
"cfg_strength": ss_guidance_strength,
|
222 |
+
},
|
223 |
+
slat_sampler_params={
|
224 |
+
"steps": slat_sampling_steps,
|
225 |
+
"cfg_strength": slat_guidance_strength,
|
226 |
+
},
|
227 |
+
)
|
|
|
|
|
|
|
228 |
|
229 |
+
video = render_utils.render_video(outputs['gaussian'][0], num_frames=120)['color']
|
230 |
+
video_geo = render_utils.render_video(outputs['mesh'][0], num_frames=120)['normal']
|
231 |
+
video = [np.concatenate([video[i], video_geo[i]], axis=1) for i in range(len(video))]
|
232 |
+
new_trial_id = str(uuid.uuid4())
|
233 |
+
video_path = f"{TMP_DIR}/{new_trial_id}.mp4"
|
234 |
+
os.makedirs(os.path.dirname(video_path), exist_ok=True)
|
235 |
+
imageio.mimsave(video_path, video, fps=15)
|
236 |
+
state = pack_state(outputs['gaussian'][0], outputs['mesh'][0], new_trial_id)
|
237 |
+
|
238 |
+
torch.cuda.empty_cache()
|
239 |
+
return state, video_path
|
|
|
|
|
240 |
|
241 |
except Exception as e:
|
242 |
print(f"Error in image_to_3d: {str(e)}")
|
243 |
+
torch.cuda.empty_cache()
|
|
|
244 |
return None, None
|
245 |
|
246 |
|
|
|
492 |
allowed_paths=[PERSISTENT_DIR, TMP_DIR],
|
493 |
server_name="0.0.0.0",
|
494 |
server_port=7860,
|
495 |
+
show_error=True
|
|
|
496 |
)
|
497 |
|
498 |
except Exception as e:
|