Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,3 @@
|
|
| 1 |
-
import torch
|
| 2 |
import gradio as gr
|
| 3 |
-
from diffusers import FluxPipeline
|
| 4 |
-
|
| 5 |
-
# Load FLUX.1-dev model
|
| 6 |
-
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
|
| 7 |
-
pipe.enable_model_cpu_offload() # Saves VRAM by offloading to CPU if needed
|
| 8 |
-
|
| 9 |
-
def generate_image(prompt):
|
| 10 |
-
"""Generates an image based on user input"""
|
| 11 |
-
image = pipe(
|
| 12 |
-
prompt,
|
| 13 |
-
height=1024,
|
| 14 |
-
width=1024,
|
| 15 |
-
guidance_scale=3.5,
|
| 16 |
-
num_inference_steps=50,
|
| 17 |
-
max_sequence_length=512,
|
| 18 |
-
generator=torch.Generator("cpu").manual_seed(0)
|
| 19 |
-
).images[0]
|
| 20 |
-
|
| 21 |
-
return image
|
| 22 |
-
|
| 23 |
-
# Create Gradio interface
|
| 24 |
-
demo = gr.Interface(
|
| 25 |
-
fn=generate_image,
|
| 26 |
-
inputs=gr.Textbox(label="Enter your prompt"),
|
| 27 |
-
outputs=gr.Image(label="Generated Image"),
|
| 28 |
-
title="FLUX Image Generator",
|
| 29 |
-
description="Enter a text prompt and generate an image using FLUX.1-dev"
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
-
if __name__ == "__main__":
|
| 33 |
-
demo.launch()
|
| 34 |
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
gr.load("models/black-forest-labs/FLUX.1-dev").launch()
|