Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import DiffusionPipeline
|
3 |
+
import torch
|
4 |
+
|
5 |
+
# Load the FLUX.1-dev model from Hugging Face
|
6 |
+
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.float16)
|
7 |
+
pipe = pipe.to("cuda")
|
8 |
+
|
9 |
+
# Define a function to generate an image based on the prompt
|
10 |
+
def generate_image(prompt: str):
|
11 |
+
image = pipe(prompt).images[0]
|
12 |
+
return image
|
13 |
+
|
14 |
+
# Create the Gradio interface
|
15 |
+
iface = gr.Interface(fn=generate_image,
|
16 |
+
inputs="text",
|
17 |
+
outputs="image",
|
18 |
+
title="Text-to-Image with FLUX.1-dev",
|
19 |
+
description="Enter a prompt to generate an image using the FLUX.1-dev model.")
|
20 |
+
|
21 |
+
# Launch the app
|
22 |
+
iface.launch()
|