akhaliq HF staff commited on
Commit
fa2ca72
1 Parent(s): e113a69

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import replicate
3
+ import os
4
+
5
+ def generate_image(prompt, api_key):
6
+ # Set the API key for the current session
7
+ os.environ["REPLICATE_API_TOKEN"] = api_key
8
+ # Prepare the input for the model
9
+ inputs = {
10
+ "prompt": prompt,
11
+ "prompt_upsampling": True
12
+ }
13
+ # Run the model and get the output URL
14
+ output_url = replicate.run(
15
+ "black-forest-labs/flux-1.1-pro",
16
+ input=inputs
17
+ )
18
+ # Return the generated image URL
19
+ return output_url[0]
20
+
21
+ # Create the Gradio interface
22
+ iface = gr.Interface(
23
+ fn=generate_image,
24
+ inputs=[
25
+ gr.Textbox(lines=2, placeholder="Enter your prompt here...", label="Prompt"),
26
+ gr.Textbox(
27
+ lines=1,
28
+ placeholder="Enter your Replicate API key...",
29
+ type="password",
30
+ label="Replicate API Key"
31
+ )
32
+ ],
33
+ outputs=gr.Image(type="auto"),
34
+ title="FLUX 1.1 Pro Text-to-Image Generator",
35
+ description="Generate images from text prompts using the FLUX 1.1 Pro model."
36
+ )
37
+
38
+ # Launch the Gradio app
39
+ iface.launch()