Create app.py
Browse files
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 on CPU
|
| 6 |
+
model_id = "sergey-leshchenko/flux-realismo"
|
| 7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id)
|
| 8 |
+
pipe.to("cpu")
|
| 9 |
+
|
| 10 |
+
def generate(prompt, guidance_scale=7.5, steps=25):
|
| 11 |
+
image = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=steps).images[0]
|
| 12 |
+
return image
|
| 13 |
+
|
| 14 |
+
# Gradio interface
|
| 15 |
+
gr.Interface(
|
| 16 |
+
fn=generate,
|
| 17 |
+
inputs=[
|
| 18 |
+
gr.Textbox(label="Prompt", placeholder="Describe your image..."),
|
| 19 |
+
gr.Slider(minimum=1, maximum=20, value=7.5, step=0.5, label="Guidance Scale"),
|
| 20 |
+
gr.Slider(minimum=10, maximum=50, value=25, step=1, label="Inference Steps")
|
| 21 |
+
],
|
| 22 |
+
outputs=gr.Image(type="pil"),
|
| 23 |
+
title="Flux-Realismo Image Generator (CPU)",
|
| 24 |
+
description="Generate realistic images using the Flux-Realismo model on CPU. May be slow."
|
| 25 |
+
).launch()
|