Naveenlara commited on
Commit
c10b4ed
·
verified ·
1 Parent(s): e3d8ca0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ # Load the stable diffusion model
6
+ pipe = StableDiffusionPipeline.from_pretrained(
7
+ "CompVis/stable-diffusion-v1-4",
8
+ revision="fp16",
9
+ torch_dtype=torch.float16
10
+ )
11
+ pipe.to("cuda" if torch.cuda.is_available() else "cpu")
12
+
13
+ def generate_image(prompt):
14
+ image = pipe(prompt).images[0]
15
+ return image
16
+
17
+ # Create a Gradio interface
18
+ gr.Interface(
19
+ fn=generate_image,
20
+ inputs=gr.Textbox(lines=2, placeholder="Enter an exercise like 'child to cobra pose'"),
21
+ outputs="image",
22
+ title="AI Exercise Visual Generator",
23
+ description="Enter an exercise name. This tool will generate a visual representation using AI."
24
+ ).launch()