CJHauser commited on
Commit
2ba253c
·
verified ·
1 Parent(s): cb019cb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ # Load the model (will take time and ~6GB+ RAM)
6
+ pipe = StableDiffusionPipeline.from_pretrained(
7
+ "runwayml/stable-diffusion-v1-5",
8
+ torch_dtype=torch.float32,
9
+ low_cpu_mem_usage=True,
10
+ use_auth_token=True # Optional if you already logged in with huggingface-cli
11
+ ).to("cpu")
12
+
13
+ # Inference function
14
+ def generate_image(prompt):
15
+ image = pipe(prompt, num_inference_steps=15).images[0]
16
+ return image
17
+
18
+ # Gradio app
19
+ gr.Interface(
20
+ fn=generate_image,
21
+ inputs=gr.Textbox(placeholder="A dragon playing guitar under a disco ball"),
22
+ outputs="image",
23
+ title="CJ's Image Generator",
24
+ description="Enter a prompt and summon an image like an AI sorcerer with CPU lag."
25
+ ).launch(share=True)