File size: 1,093 Bytes
d999db0
c2a5f72
 
d999db0
c2a5f72
 
ec8835a
d999db0
eda7a8f
c2a5f72
eda7a8f
 
 
 
 
 
 
 
c2a5f72
 
eda7a8f
c2a5f72
 
 
899ac64
c2a5f72
899ac64
 
c2a5f72
 
532a147
c2a5f72
 
 
899ac64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
from diffusers import ShapEPipeline
from diffusers.utils import export_to_gif

# Load the ShapE model
ckpt_id = "openai/shap-e"
pipe = ShapEPipeline.from_pretrained(ckpt_id)

def generate_shap_e_gif(prompt, progress=gr.Progress()):
    guidance_scale = 15.0
    num_inference_steps = 64
    progress(0, desc="Starting...")
    images = []
    
    for i in progress.tqdm(range(num_inference_steps), desc="Generating GIF"):
        image = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=1).images[0]
        images.append(image)
        progress(i+1, total=num_inference_steps, desc="Processing")

    gif_path = export_to_gif(images, f"{prompt}_3d.gif")
    progress(1, desc="Completed")
    return gif_path

# Create the Gradio interface
demo = gr.Interface(
    fn=generate_shap_e_gif,
    inputs=gr.Textbox(lines=2, placeholder="Enter a prompt"),
    outputs=gr.File(),
    title="ShapE 3D GIF Generator",
    description="Enter a prompt to generate a 3D GIF using the ShapE model."
).queue()

# Run the app
if __name__ == "__main__":
    demo.launch()