Testing / model.py
Masrkai's picture
Rename app.py to model.py
487d3dd verified
raw
history blame
726 Bytes
import torch
from diffusers import ShapEPipeline
from diffusers.utils import export_to_gif
# Define checkpoint ID and load pipeline on CPU
ckpt_id = "openai/shap-e"
pipe = ShapEPipeline.from_pretrained(ckpt_id).to("cpu")
# Define generation parameters
guidance_scale = 10.0 # Lowered for efficiency on CPU
num_inference_steps = 32 # Reduced steps for CPU performance
prompt = "a shark"
# Generate images from the prompt with reduced settings
images = pipe(
prompt=prompt,
guidance_scale=guidance_scale,
num_inference_steps=num_inference_steps,
size=256, # Image size for the model
).images
# Export images to GIF format
gif_path = export_to_gif(images, "shark_3d.gif")
print(f"GIF saved at {gif_path}")