File size: 867 Bytes
9d1b8e4
7467e8a
793d385
9d1b8e4
793d385
fe2046f
793d385
f6f44a7
 
7467e8a
 
 
 
 
 
 
 
 
f6f44a7
d709633
7467e8a
 
 
 
 
 
 
d709633
f6f44a7
7467e8a
93e97ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
import torch
from diffusers import DiffusionPipeline

# Load the model with authentication
pipe = DiffusionPipeline.from_pretrained("Shakker-Labs/AWPortrait-FL", torch_dtype=torch.bfloat16, use_auth_token=True)
pipe.enable_model_cpu_offload()  # Save some VRAM by offloading the model to CPU

def generate_image(prompt):
    image = pipe(
        prompt,
        height=1024,
        width=1024,
        guidance_scale=3.5,
        num_inference_steps=50,
        max_sequence_length=512,
        generator=torch.Generator("cpu").manual_seed(0)
    ).images[0]
    return image

# Create the UI
ui = gr.Interface(
    generate_image,
    gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
    "image",
    title="FLUX.1-dev Image Generator",
    description="Generate images using the FLUX.1-dev model.",
)

# Launch the UI
ui.launch()