Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,22 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from diffusers import FluxPipeline
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
| 5 |
-
# Load the model
|
| 6 |
-
|
| 7 |
-
pipe.to("cpu") # Set to CPU
|
| 8 |
|
| 9 |
-
# Define the function to generate an image from a given prompt
|
| 10 |
def generate_image(prompt):
|
| 11 |
-
image
|
| 12 |
-
|
| 13 |
-
guidance_scale=3.5,
|
| 14 |
-
width=768, height=1024).images[0]
|
| 15 |
-
image.save(f"example.png")
|
| 16 |
return image
|
| 17 |
|
| 18 |
-
# Create
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
fn=inference,
|
| 26 |
-
inputs=gr.Textbox(lines=2, placeholder="Enter your image description here..."),
|
| 27 |
-
outputs="image",
|
| 28 |
-
title="Text-to-Image Generator",
|
| 29 |
-
description="Enter a text prompt to generate an image using AWPortrait-FL."
|
| 30 |
)
|
| 31 |
|
| 32 |
-
# Launch the Gradio
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import Flux1
|
| 3 |
|
| 4 |
+
# Load the model
|
| 5 |
+
model = Flux1.from_pretrained("black-forest-labs/flux-1-dev")
|
|
|
|
| 6 |
|
|
|
|
| 7 |
def generate_image(prompt):
|
| 8 |
+
# Generate an image using the model
|
| 9 |
+
image = model(prompt)
|
|
|
|
|
|
|
|
|
|
| 10 |
return image
|
| 11 |
|
| 12 |
+
# Create the Gradio Interface
|
| 13 |
+
demo = gr.Interface(
|
| 14 |
+
fn=generate_image,
|
| 15 |
+
inputs=gr.Textbox(label="Prompt"),
|
| 16 |
+
outputs=gr.Image(label="Generated Image"),
|
| 17 |
+
title="FLUX.1-dev Image Generation Bot",
|
| 18 |
+
description="Enter a prompt and generate an image using the FLUX.1-dev model."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
)
|
| 20 |
|
| 21 |
+
# Launch the Gradio Interface
|
| 22 |
+
demo.launch()
|