| |
| import torch |
| from diffusers import ShapEPipeline |
| from diffusers.utils import export_to_gif |
|
|
| |
| def load_pipeline(): |
| ckpt_id = "openai/shap-e" |
| pipe = ShapEPipeline.from_pretrained(ckpt_id, torch_dtype=torch.float32, trust_remote_code=True).to("cpu") |
| return pipe |
|
|
| |
| def generate_3d_gif(pipe, prompt, guidance_scale=10.0, num_inference_steps=32, size=256): |
| images = pipe( |
| prompt=prompt, |
| guidance_scale=guidance_scale, |
| num_inference_steps=num_inference_steps, |
| size=size |
| ).images |
| gif_path = export_to_gif(images, "generated_3d.gif") |
| return gif_path |
|
|