Spaces:
Sleeping
Sleeping
Raumkommander2
commited on
Commit
·
9df1739
1
Parent(s):
07a6cea
inital deployment
Browse files- app.py +26 -0
- requirements.txt +8 -0
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
from diffusers import StableDiffusionPipeline, LCMScheduler
|
4 |
+
|
5 |
+
# Load the pre-trained Real-Time LCM model
|
6 |
+
model_id = "SimianLuo/LCM_Dreamshaper_v7"
|
7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
8 |
+
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
|
9 |
+
pipe.to("cuda")
|
10 |
+
|
11 |
+
# Function to generate images
|
12 |
+
def generate_image(prompt: str):
|
13 |
+
image = pipe(prompt, num_inference_steps=4).images[0]
|
14 |
+
return image
|
15 |
+
|
16 |
+
# Create Gradio interface
|
17 |
+
iface = gr.Interface(
|
18 |
+
fn=generate_image,
|
19 |
+
inputs=gr.Textbox(label="Enter a prompt"),
|
20 |
+
outputs=gr.Image(label="Generated Image"),
|
21 |
+
title="Real-Time LCM Image Generator",
|
22 |
+
description="Enter a prompt and get an AI-generated image in real time using Latent Consistency Models."
|
23 |
+
)
|
24 |
+
|
25 |
+
if __name__ == "__main__":
|
26 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
diffusers
|
3 |
+
transformers
|
4 |
+
accelerate
|
5 |
+
gradio
|
6 |
+
safetensors
|
7 |
+
xformers
|
8 |
+
torchvision
|