File size: 924 Bytes
98959a9
 
5e69d3c
d13afd7
98959a9
 
 
d13afd7
ddc7e76
98959a9
 
 
 
 
 
 
 
 
 
5e69d3c
98959a9
 
 
 
 
 
 
5e69d3c
 
98959a9
 
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 torch
from diffusers import FluxPipeline
import gradio as gr

# Initialize the model
pipe = FluxPipeline.from_pretrained("Shakker-Labs/AWPortrait-FL", torch_dtype=torch.bfloat16)
pipe.to("cuda")

def generate_image(prompt):
    # Generate the image
    image = pipe(prompt, 
                 num_inference_steps=24, 
                 guidance_scale=3.5,
                 width=768, height=1024,
                ).images[0]
    # Save the image
    image_path = "generated_image.png"
    image.save(image_path)
    return image_path

# Define the Gradio interface
interface = gr.Interface(
    fn=generate_image,
    inputs=gr.Textbox(label="Prompt", placeholder="Enter your prompt here..."),
    outputs=gr.Image(type="file", label="Generated Image"),
    title="Image Generator",
    description="Generate images based on the given prompt using the FluxPipeline model."
)

# Launch the Gradio app
interface.launch()