ciaochaos commited on
Commit
66a68b8
1 Parent(s): de2e35a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -85,7 +85,7 @@ async def load_image_from_url(url):
85
  return Image.open(io.BytesIO(image_data))
86
 
87
 
88
- async def greet(my_prompt, control_weight, correct_level, padding_ratio, point_style, my_seed, size):
89
  url = API_URL
90
  headers = {
91
  'x-qrbtf-key': f'{API_KEY}',
@@ -97,6 +97,8 @@ async def greet(my_prompt, control_weight, correct_level, padding_ratio, point_s
97
  size_value = sizes[size]['value']
98
  point_style_value = anchor_styles[point_style]['value']
99
 
 
 
100
  payload = {
101
  'url': 'https://qrbtf.com/',
102
  'prompt': my_prompt,
@@ -106,6 +108,8 @@ async def greet(my_prompt, control_weight, correct_level, padding_ratio, point_s
106
  'point_style': point_style_value,
107
  'seed': my_seed,
108
  'size': size_value,
 
 
109
  }
110
 
111
  async with aiohttp.ClientSession(headers=headers) as session:
@@ -151,7 +155,6 @@ with gr.Blocks() as demo:
151
  )
152
  with gr.Accordion("More options", open=False):
153
  with gr.Row():
154
- promptsTuning = gr.Checkbox(label="Prompts tuning", value=True, interactive=True)
155
  seed = gr.Slider(
156
  label="Seed",
157
  minimum=-1,
@@ -160,20 +163,23 @@ with gr.Blocks() as demo:
160
  value=-1,
161
  interactive=True,
162
  )
 
163
 
164
  with gr.Row():
165
- ControlWeight = gr.Slider(0.5, 1.5, value=1.0, label="ControlNet weight", info="", interactive=True)
166
  marginScale = gr.Slider(0, 0.5, value=0.2, label="Padding ratio", info="", interactive=True)
 
167
 
168
  with gr.Row():
169
  SizeSelection = gr.Dropdown(
170
  [size['label'] for size in sizes], value=sizes[0]['label'], label="Size", type="index", interactive=True)
171
  errorRate = gr.Dropdown(
172
- [level['label'] for level in correct_levels], value=correct_levels[0]['label'], label="Error correction", type="index",
173
  interactive=True)
174
-
175
- anchorStyle = gr.Dropdown(
176
- [anchor['label'] for anchor in anchor_styles], value=anchor_styles[0]['label'], label="Anchor style", type="index", interactive=True)
 
 
177
 
178
  with gr.Column():
179
  with gr.Row():
@@ -184,6 +190,6 @@ with gr.Blocks() as demo:
184
  with gr.Row():
185
  out = gr.Image(shape=(1, 1))
186
 
187
- btn.click(greet, [prompt, ControlWeight, errorRate, marginScale, anchorStyle, seed, SizeSelection], out)
188
 
189
  demo.launch()
 
85
  return Image.open(io.BytesIO(image_data))
86
 
87
 
88
+ async def greet(my_prompt, control_weight, correct_level, padding_ratio, hires_rate, point_style, my_seed, size):
89
  url = API_URL
90
  headers = {
91
  'x-qrbtf-key': f'{API_KEY}',
 
97
  size_value = sizes[size]['value']
98
  point_style_value = anchor_styles[point_style]['value']
99
 
100
+ is_hires = not (hires_rate < 0.01)
101
+
102
  payload = {
103
  'url': 'https://qrbtf.com/',
104
  'prompt': my_prompt,
 
108
  'point_style': point_style_value,
109
  'seed': my_seed,
110
  'size': size_value,
111
+ 'is_hires': is_hires,
112
+ 'hires_rate': hires_rate,
113
  }
114
 
115
  async with aiohttp.ClientSession(headers=headers) as session:
 
155
  )
156
  with gr.Accordion("More options", open=False):
157
  with gr.Row():
 
158
  seed = gr.Slider(
159
  label="Seed",
160
  minimum=-1,
 
163
  value=-1,
164
  interactive=True,
165
  )
166
+ ControlWeight = gr.Slider(0.5, 1.5, value=1.0, label="ControlNet weight", info="", interactive=True)
167
 
168
  with gr.Row():
 
169
  marginScale = gr.Slider(0, 0.5, value=0.2, label="Padding ratio", info="", interactive=True)
170
+ hiresRate = gr.Slider(0, 0.5, value=0, label="Image restoration rate", info="", interactive=True)
171
 
172
  with gr.Row():
173
  SizeSelection = gr.Dropdown(
174
  [size['label'] for size in sizes], value=sizes[0]['label'], label="Size", type="index", interactive=True)
175
  errorRate = gr.Dropdown(
176
+ [level['label'] for level in correct_levels], value=correct_levels[1]['label'], label="Error correction", type="index",
177
  interactive=True)
178
+
179
+ with gr.Row():
180
+ promptsTuning = gr.Checkbox(label="Prompts tuning", value=True, interactive=True)
181
+ anchorStyle = gr.Dropdown(
182
+ [anchor['label'] for anchor in anchor_styles], value=anchor_styles[0]['label'], label="Anchor style", type="index", interactive=True)
183
 
184
  with gr.Column():
185
  with gr.Row():
 
190
  with gr.Row():
191
  out = gr.Image(shape=(1, 1))
192
 
193
+ btn.click(greet, [prompt, ControlWeight, errorRate, marginScale, hiresRate, anchorStyle, seed, SizeSelection], out)
194
 
195
  demo.launch()