# [Previous imports and utility functions remain exactly the same until image_to_3d] def image_to_3d( image: Image.Image, seed: int, ss_guidance_strength: float, ss_sampling_steps: int, slat_guidance_strength: float, slat_sampling_steps: int, req: gr.Request, ) -> Tuple[dict, str, str]: """ Convert an image to a 3D model. """ user_dir = os.path.join(TMP_DIR, str(req.session_hash)) outputs = pipeline.run( image, seed=seed, formats=["gaussian", "mesh"], preprocess_image=False, sparse_structure_sampler_params={ "steps": ss_sampling_steps, "cfg_strength": ss_guidance_strength, }, slat_sampler_params={ "steps": slat_sampling_steps, "cfg_strength": slat_guidance_strength, }, ) video = render_utils.render_video(outputs['gaussian'][0], num_frames=120)['color'] video_geo = render_utils.render_video(outputs['mesh'][0], num_frames=120)['normal'] video = [np.concatenate([video[i], video_geo[i]], axis=1) for i in range(len(video))] trial_id = str(uuid.uuid4()) video_path = os.path.join(user_dir, f"{trial_id}.mp4") imageio.mimsave(video_path, video, fps=15) # Generate full quality GLB glb = postprocessing_utils.to_glb( outputs['gaussian'][0], outputs['mesh'][0], simplify=0.0, # No simplification fill_holes=True, fill_holes_max_size=0.04, texture_size=2048, # Maximum texture size verbose=False ) full_glb_path = os.path.join(user_dir, f"{trial_id}_full.glb") glb.export(full_glb_path) state = pack_state(outputs['gaussian'][0], outputs['mesh'][0], trial_id) return state, video_path, full_glb_path # [Rest of the code remains exactly the same, except for the event handler which needs to be updated] generate_btn.click( get_seed, inputs=[randomize_seed, seed], outputs=[seed], ).then( image_to_3d, inputs=[image_prompt, seed, ss_guidance_strength, ss_sampling_steps, slat_guidance_strength, slat_sampling_steps], outputs=[output_buf, video_output, download_full], ).then( lambda: [gr.Button(interactive=True), gr.Button(interactive=True), gr.Button(interactive=False)], outputs=[download_full, extract_glb_btn, download_reduced], ) # [Rest of the code remains exactly the same]