File size: 963 Bytes
81ac59f
d709633
9d1b8e4
 
d709633
 
 
f6f44a7
d709633
f6f44a7
d709633
 
 
 
 
f6f44a7
d709633
 
 
f6f44a7
 
 
d709633
 
 
 
 
 
 
 
f6f44a7
d709633
 
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
33
34
import torch
from diffusers import FluxPipeline
import gradio as gr

# Load the model and set to CPU
pipe = FluxPipeline.from_pretrained("Shakker-Labs/AWPortrait-FL", torch_dtype=torch.float32)
pipe.to("cpu")  # Set to CPU

# Define the function to generate an image from a given prompt
def generate_image(prompt):
    image = pipe(prompt, 
                 num_inference_steps=24, 
                 guidance_scale=3.5,
                 width=768, height=1024).images[0]
    image.save(f"example.png")
    return image

# Create a Gradio interface
def inference(prompt):
    image = generate_image(prompt)
    return image

# Gradio Interface
interface = gr.Interface(
    fn=inference, 
    inputs=gr.Textbox(lines=2, placeholder="Enter your image description here..."), 
    outputs="image",
    title="Text-to-Image Generator",
    description="Enter a text prompt to generate an image using AWPortrait-FL."
)

# Launch the Gradio interface
interface.launch()