Spaces:
Runtime error
Runtime error
File size: 1,133 Bytes
fa2ca72 3bcc82e fa2ca72 3bcc82e fa2ca72 3bcc82e fa2ca72 3bcc82e fa2ca72 |
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 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import gradio as gr
import replicate
import os
def generate_image(prompt, api_key):
# Set the API key for the current session
os.environ["REPLICATE_API_TOKEN"] = api_key
# Prepare the input for the model
inputs = {
"prompt": prompt,
"prompt_upsampling": True
}
# Run the model and get the output URL
output_url = replicate.run(
"black-forest-labs/flux-1.1-pro",
input=inputs
)
# Return the generated image URL
return output_url[0]
# Create the Gradio interface
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."
)
# Launch the Gradio app
iface.launch()
|