prograk commited on
Commit
690873f
·
verified ·
1 Parent(s): f7107ef

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from diffusers import StableDiffusion3Pipeline
4
+
5
+ def image_generation(prompt):
6
+ # is_cuda = False
7
+ pipeline = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers",
8
+ torch_dtype=torch.float32,
9
+ text_encoder_3=None,
10
+ tokenizer_3=None)
11
+ # pipeline.enable_model_cpu_offload()
12
+ pipeline.to('cpu')
13
+
14
+ image = pipeline(
15
+ prompt=prompt,
16
+ negative_prompt="blurred, ugly, watermark, low resolution, blurry",
17
+ num_inference_steps=10,
18
+ height=192,
19
+ width=192,
20
+ guidance_scale=7.0
21
+ ).images[0]
22
+
23
+ return image
24
+
25
+ # image_generation("A magicion cat doing spell")
26
+
27
+ gr.close_all()
28
+
29
+ interface = gr.Interface(fn=image_generation,
30
+ inputs=[gr.Textbox(label="Enter your prompt", lines=2)],
31
+ outputs=[gr.Image(type="pil", label="Generated Image")],
32
+ title="@GenAILearniverse Project 8: Image creation using Stable Diffusion 3 Model",
33
+ description="THIS APPLICATION WILL BE USED TO GENERATE AWESOME IMAGES USING SD3 MODEL.")
34
+
35
+ interface.launch()