The-Best-Codes commited on
Commit
c2a5f72
·
1 Parent(s): d999db0
Files changed (2) hide show
  1. app.py +30 -4
  2. requirements.txt +3 -0
app.py CHANGED
@@ -1,7 +1,33 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import torch
3
+ from diffusers import ShapEPipeline
4
+ from diffusers.utils import export_to_gif
5
 
6
+ # Load the ShapE model
7
+ ckpt_id = "openai/shap-e"
8
+ pipe = ShapEPipeline.from_pretrained(ckpt_id).to("cuda")
9
 
10
+ def generate_shap_e_gif(prompt):
11
+ guidance_scale = 15.0
12
+ images = pipe(
13
+ prompt,
14
+ guidance_scale=guidance_scale,
15
+ num_inference_steps=64,
16
+ size=256,
17
+ ).images
18
+
19
+ gif_path = export_to_gif(images, f"{prompt}_3d.gif")
20
+ return gif_path
21
+
22
+ # Create the Gradio interface
23
+ iface = gr.Interface(
24
+ fn=generate_shap_e_gif,
25
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Enter a prompt"),
26
+ outputs="file",
27
+ title="ShapE 3D GIF Generator",
28
+ description="Enter a prompt to generate a 3D GIF using the ShapE model."
29
+ )
30
+
31
+ # Run the app
32
+ if __name__ == "__main__":
33
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ diffusers==0.29.0.dev0
2
+ gradio==4.36.0
3
+ torch==2.3.1