NihalGazi commited on
Commit
b111b48
·
verified ·
1 Parent(s): 07e7c2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
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.inputs.Textbox(label="Prompt", placeholder="Enter your image prompt..."),
35
- gr.inputs.Slider(minimum=100, maximum=1024, step=1, default=512, label="Width"),
36
- gr.inputs.Slider(minimum=100, maximum=1024, step=1, default=512, label="Height"),
37
- gr.inputs.Number(label="Seed", default=0),
38
- gr.inputs.Checkbox(label="Randomize Seed")
39
  ],
40
- outputs=gr.outputs.Image(type="pil"),
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
  )