Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,39 +5,33 @@ import gradio as gr
|
|
5 |
from io import BytesIO
|
6 |
|
7 |
def generate_image(prompt, width, height, seed, randomize):
|
8 |
-
# If randomized seed is checked, generate a random seed.
|
9 |
if randomize:
|
10 |
seed = random.randint(0, 99999)
|
11 |
-
# Fetch the secret URL from environment variables.
|
12 |
-
# The URL should be stored in an env variable named "FLUX_URL".
|
13 |
base_url = os.environ.get("FLUX_URL")
|
14 |
if not base_url:
|
15 |
return "Error: FLUX_URL environment variable not set."
|
16 |
-
# Replace placeholders in the URL.
|
17 |
url = (
|
18 |
base_url.replace("[prompt]", prompt)
|
19 |
.replace("[w]", str(width))
|
20 |
.replace("[h]", str(height))
|
21 |
.replace("[seed]", str(seed))
|
22 |
)
|
23 |
-
# Fetch the image from the URL.
|
24 |
response = requests.get(url)
|
25 |
return BytesIO(response.content)
|
26 |
|
27 |
-
# Gradio Interface setup with title and description.
|
28 |
title = "Unlimited FLUX-Pro"
|
29 |
description = "Here you can use the FLUX-Pro as much as you want without limits"
|
30 |
|
31 |
iface = gr.Interface(
|
32 |
fn=generate_image,
|
33 |
inputs=[
|
34 |
-
gr.
|
35 |
-
gr.
|
36 |
-
gr.
|
37 |
-
gr.
|
38 |
-
gr.
|
39 |
],
|
40 |
-
outputs=gr.
|
41 |
title=title,
|
42 |
description=description,
|
43 |
)
|
|
|
5 |
from io import BytesIO
|
6 |
|
7 |
def generate_image(prompt, width, height, seed, randomize):
|
|
|
8 |
if randomize:
|
9 |
seed = random.randint(0, 99999)
|
|
|
|
|
10 |
base_url = os.environ.get("FLUX_URL")
|
11 |
if not base_url:
|
12 |
return "Error: FLUX_URL environment variable not set."
|
|
|
13 |
url = (
|
14 |
base_url.replace("[prompt]", prompt)
|
15 |
.replace("[w]", str(width))
|
16 |
.replace("[h]", str(height))
|
17 |
.replace("[seed]", str(seed))
|
18 |
)
|
|
|
19 |
response = requests.get(url)
|
20 |
return BytesIO(response.content)
|
21 |
|
|
|
22 |
title = "Unlimited FLUX-Pro"
|
23 |
description = "Here you can use the FLUX-Pro as much as you want without limits"
|
24 |
|
25 |
iface = gr.Interface(
|
26 |
fn=generate_image,
|
27 |
inputs=[
|
28 |
+
gr.Textbox(label="Prompt", placeholder="Enter your image prompt..."),
|
29 |
+
gr.Slider(minimum=100, maximum=1024, step=1, value=512, label="Width"),
|
30 |
+
gr.Slider(minimum=100, maximum=1024, step=1, value=512, label="Height"),
|
31 |
+
gr.Number(label="Seed", value=0),
|
32 |
+
gr.Checkbox(label="Randomize Seed")
|
33 |
],
|
34 |
+
outputs=gr.Image(type="pil"),
|
35 |
title=title,
|
36 |
description=description,
|
37 |
)
|