File size: 745 Bytes
eae7b8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import torch
from diffusers import FluxPipeline
import gradio as gr

# Load the FLUX pipeline
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
pipe.enable_model_cpu_offload()  # For memory efficiency

def generate_image(prompt):
    # Generate the image based on user prompt
    image = pipe(prompt, height=512, width=512, guidance_scale=3.5, num_inference_steps=50).images[0]
    return image

# Create a Gradio interface
interface = gr.Interface(
    fn=generate_image,
    inputs="text",
    outputs="image",
    title="FLUX Image Generator",
    description="Enter a text prompt to generate a futuristic 3D-style image using the FLUX model."
)

if __name__ == "__main__":
    interface.launch()