Spaces:
Running
Running
File size: 1,395 Bytes
07e7c2e 3930741 07e7c2e 0ac5fe7 07e7c2e 0e6fa69 07e7c2e 3930741 07e7c2e b111b48 5c7311a b111b48 0e6fa69 07e7c2e b111b48 07e7c2e |
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 os
import random
import requests
import gradio as gr
from PIL import Image
from io import BytesIO
def generate_image(prompt, width, height, seed, randomize):
print(prompt+"\n\n")
if randomize:
seed = random.randint(0, 9999999)
base_url = os.environ.get("FLUX_URL")
if not base_url:
return "Error: FLUX_URL environment variable not set."
url = (
base_url.replace("[prompt]", prompt)
.replace("[w]", str(width))
.replace("[h]", str(height))
.replace("[seed]", str(seed))
)
response = requests.get(url)
if response.status_code == 200:
image = Image.open(BytesIO(response.content))
return image
else:
return "Failed to retrieve image."
title = "Unlimited FLUX-Pro"
description = "Here you can use the FLUX-Pro as much as you want without limits"
iface = gr.Interface(
fn=generate_image,
inputs=[
gr.Textbox(label="Prompt", placeholder="Enter your image prompt..."),
gr.Slider(minimum=512, maximum=1280, step=16, value=1280, label="Width"),
gr.Slider(minimum=512, maximum=1280, step=16, value=1280, label="Height"),
gr.Number(label="Seed", value=0),
gr.Checkbox(label="Randomize Seed", value=True)
],
outputs=gr.Image(type="pil"),
title=title,
description=description,
)
if __name__ == "__main__":
iface.launch()
|