|
import gradio as gr |
|
import replicate |
|
import os |
|
|
|
def generate_image(prompt, api_key): |
|
|
|
os.environ["REPLICATE_API_TOKEN"] = api_key |
|
|
|
|
|
inputs = { |
|
"prompt": prompt, |
|
"prompt_upsampling": True |
|
} |
|
|
|
|
|
output_url = replicate.run( |
|
"black-forest-labs/flux-1.1-pro", |
|
input=inputs |
|
) |
|
|
|
|
|
return output_url[0] |
|
|
|
|
|
iface = gr.Interface( |
|
fn=generate_image, |
|
inputs=[ |
|
gr.Textbox( |
|
lines=2, |
|
placeholder="Enter your prompt here...", |
|
label="Prompt" |
|
), |
|
gr.Textbox( |
|
lines=1, |
|
placeholder="Enter your Replicate API key...", |
|
type="password", |
|
label="Replicate API Key" |
|
) |
|
], |
|
outputs=gr.Image(type="auto"), |
|
title="FLUX 1.1 Pro Text-to-Image Generator", |
|
description="Generate images from text prompts using the FLUX 1.1 Pro model." |
|
) |
|
|
|
|
|
iface.launch() |
|
|