Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from diffusers import DiffusionPipeline
|
| 4 |
+
|
| 5 |
+
MODEL_ID = "black-forest-labs/FLUX.1-schnell"
|
| 6 |
+
|
| 7 |
+
# Pipeline laden (CPU)
|
| 8 |
+
pipe = DiffusionPipeline.from_pretrained(
|
| 9 |
+
MODEL_ID,
|
| 10 |
+
torch_dtype=torch.float32
|
| 11 |
+
)
|
| 12 |
+
pipe.to("cpu")
|
| 13 |
+
|
| 14 |
+
def generate(prompt):
|
| 15 |
+
image = pipe(
|
| 16 |
+
prompt=prompt,
|
| 17 |
+
num_inference_steps=20,
|
| 18 |
+
guidance_scale=3.5
|
| 19 |
+
).images[0]
|
| 20 |
+
return image
|
| 21 |
+
|
| 22 |
+
demo = gr.Interface(
|
| 23 |
+
fn=generate,
|
| 24 |
+
inputs=gr.Textbox(
|
| 25 |
+
label="Prompt",
|
| 26 |
+
placeholder="anime girl with fennec ears sitting on a log in the woods"
|
| 27 |
+
),
|
| 28 |
+
outputs=gr.Image(type="pil"),
|
| 29 |
+
title="FLUX Text-to-Image (CPU Space)",
|
| 30 |
+
description="Runs on CPU using diffusers. Slow but works."
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
demo.launch()
|