JV A commited on
Commit
1b2dc7d
·
1 Parent(s): 8b25ecd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -9
app.py CHANGED
@@ -4,14 +4,14 @@ import json
4
  import PIL.Image
5
  from io import BytesIO
6
  import os
7
- def generate_image(prompt):
8
  # Define the API endpoint
9
  apiUrl = os.getenv("API_URL")
10
  token = os.getenv("API_TOKEN")
11
  # Define the request headers
12
  headers = {
13
  "Content-Type": "application/json",
14
- "token": token
15
  }
16
 
17
  # Define the request body
@@ -21,20 +21,20 @@ def generate_image(prompt):
21
  "tiling": False,
22
  "batch_size": 1,
23
  "prompt": prompt,
24
- "negative_prompt": "worst quality, lowres",
25
  "seed": 1234,
26
- "scheduler": "Euler a",
27
  "n_iter": 1,
28
- "steps": 25,
29
  "cfg": 11.0,
30
  "offset_noise": 0.0,
31
- "width": 512,
32
- "height": 512,
33
  "clip_skip": 1,
34
  "loras": [{"name": "", "strength": 1.0}],
35
  "embeddings": [{"name": "", "strength": 1.0}],
36
  "vae": "vae-ft-mse-840000-ema-pruned.ckpt",
37
- "restore_faces": False,
38
  "fr_model": "CodeFormer",
39
  "codeformer_weight": 0.5,
40
  "enable_hr": False,
@@ -80,7 +80,35 @@ def generate_image(prompt):
80
  # Define the Gradio interface
81
  iface = gr.Interface(
82
  fn=generate_image,
83
- inputs="text",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  outputs="image",
85
  title="Freedom Demonstration",
86
  description = """
 
4
  import PIL.Image
5
  from io import BytesIO
6
  import os
7
+ def generate_image(prompt, negative_prompt, scheduler, steps, width, height, restore_faces):
8
  # Define the API endpoint
9
  apiUrl = os.getenv("API_URL")
10
  token = os.getenv("API_TOKEN")
11
  # Define the request headers
12
  headers = {
13
  "Content-Type": "application/json",
14
+ "token": "token"
15
  }
16
 
17
  # Define the request body
 
21
  "tiling": False,
22
  "batch_size": 1,
23
  "prompt": prompt,
24
+ "negative_prompt": negative_prompt,
25
  "seed": 1234,
26
+ "scheduler": scheduler,
27
  "n_iter": 1,
28
+ "steps": steps,
29
  "cfg": 11.0,
30
  "offset_noise": 0.0,
31
+ "width": width,
32
+ "height": height,
33
  "clip_skip": 1,
34
  "loras": [{"name": "", "strength": 1.0}],
35
  "embeddings": [{"name": "", "strength": 1.0}],
36
  "vae": "vae-ft-mse-840000-ema-pruned.ckpt",
37
+ "restore_faces": restore_faces,
38
  "fr_model": "CodeFormer",
39
  "codeformer_weight": 0.5,
40
  "enable_hr": False,
 
80
  # Define the Gradio interface
81
  iface = gr.Interface(
82
  fn=generate_image,
83
+ inputs=[
84
+ gr.inputs.Textbox(label="Prompt"),
85
+ gr.inputs.Textbox(label="Negative Prompt"),
86
+ gr.inputs.Dropdown(choices=[
87
+ "Euler a",
88
+ "Euler",
89
+ "LMS",
90
+ "Heun",
91
+ "DPM2",
92
+ "DPM2 a",
93
+ "DPM++ 2S a",
94
+ "DPM++ 2M",
95
+ "DPM++ SDE",
96
+ "DPM fast",
97
+ "DPM adaptive",
98
+ "LMS Karras",
99
+ "DPM2 Karras",
100
+ "DPM2 a Karras",
101
+ "DPM++ 2S a Karras",
102
+ "DPM++ 2M Karras",
103
+ "DPM++ SDE Karras",
104
+ "DDIM",
105
+ "PLMS"
106
+ ], label="Scheduler", default="Euler a"),
107
+ gr.inputs.Slider(minimum=10, maximum=60, default=30, label="Steps"),
108
+ gr.inputs.Slider(minimum=512, maximum=1500, default=768, label="Width"),
109
+ gr.inputs.Slider(minimum=512, maximum=1500, default=768, label="Height"),
110
+ gr.inputs.Checkbox(label="Restore Faces")
111
+ ],
112
  outputs="image",
113
  title="Freedom Demonstration",
114
  description = """