Update app.py
Browse files
app.py
CHANGED
|
@@ -99,17 +99,18 @@ def generate(
|
|
| 99 |
style: str = DEFAULT_STYLE_NAME,
|
| 100 |
randomize_seed: bool = False,
|
| 101 |
use_turbo: bool = True,
|
|
|
|
| 102 |
progress=gr.Progress(track_tqdm=True),
|
| 103 |
):
|
| 104 |
prompt = str(translator.translate(prompt, 'English'))
|
| 105 |
print(f'prompt:{prompt}')
|
| 106 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
| 107 |
-
print(client_test.view_api())
|
| 108 |
|
| 109 |
prompt = apply_style(style, prompt)
|
| 110 |
strength = 0.7
|
| 111 |
images = []
|
| 112 |
-
if use_turbo:
|
| 113 |
result = client.predict(
|
| 114 |
None,
|
| 115 |
prompt,
|
|
@@ -125,6 +126,20 @@ def generate(
|
|
| 125 |
pil_image = Image.open(BytesIO(images_request.content))
|
| 126 |
images.append(pil_image)
|
| 127 |
print(f'B:{images}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
else:
|
| 129 |
seed = 0
|
| 130 |
job = client2.submit(
|
|
@@ -193,6 +208,7 @@ with gr.Blocks(css=CSS, theme="soft") as demo:
|
|
| 193 |
)
|
| 194 |
randomize_seed = gr.Checkbox(label="随机种子", value=True)
|
| 195 |
use_turbo = gr.Checkbox(label="快速生成", value=True)
|
|
|
|
| 196 |
with gr.Row(visible=True):
|
| 197 |
style_selection = gr.Radio(
|
| 198 |
show_label=True,
|
|
@@ -227,6 +243,7 @@ with gr.Blocks(css=CSS, theme="soft") as demo:
|
|
| 227 |
style_selection,
|
| 228 |
randomize_seed,
|
| 229 |
use_turbo,
|
|
|
|
| 230 |
],
|
| 231 |
outputs=[result, seed],
|
| 232 |
api_name="run",
|
|
|
|
| 99 |
style: str = DEFAULT_STYLE_NAME,
|
| 100 |
randomize_seed: bool = False,
|
| 101 |
use_turbo: bool = True,
|
| 102 |
+
use_flash: bool = False,
|
| 103 |
progress=gr.Progress(track_tqdm=True),
|
| 104 |
):
|
| 105 |
prompt = str(translator.translate(prompt, 'English'))
|
| 106 |
print(f'prompt:{prompt}')
|
| 107 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
| 108 |
+
#print(client_test.view_api())
|
| 109 |
|
| 110 |
prompt = apply_style(style, prompt)
|
| 111 |
strength = 0.7
|
| 112 |
images = []
|
| 113 |
+
if use_turbo and use_flash is False:
|
| 114 |
result = client.predict(
|
| 115 |
None,
|
| 116 |
prompt,
|
|
|
|
| 126 |
pil_image = Image.open(BytesIO(images_request.content))
|
| 127 |
images.append(pil_image)
|
| 128 |
print(f'B:{images}')
|
| 129 |
+
elif use_flash is True:
|
| 130 |
+
result = client_test.predict(
|
| 131 |
+
prompt,
|
| 132 |
+
0,
|
| 133 |
+
True,
|
| 134 |
+
api_name="/infer"
|
| 135 |
+
)
|
| 136 |
+
print(result)
|
| 137 |
+
image_url = MODEL+"file="+result
|
| 138 |
+
images_request = requests.get(image_url)
|
| 139 |
+
print(f'A:{images_request}')
|
| 140 |
+
pil_image = Image.open(BytesIO(images_request.content))
|
| 141 |
+
images.append(pil_image)
|
| 142 |
+
print(f'B:{images}')
|
| 143 |
else:
|
| 144 |
seed = 0
|
| 145 |
job = client2.submit(
|
|
|
|
| 208 |
)
|
| 209 |
randomize_seed = gr.Checkbox(label="随机种子", value=True)
|
| 210 |
use_turbo = gr.Checkbox(label="快速生成", value=True)
|
| 211 |
+
use_flash = gr.Checkbox(labe="Flash", value=False)
|
| 212 |
with gr.Row(visible=True):
|
| 213 |
style_selection = gr.Radio(
|
| 214 |
show_label=True,
|
|
|
|
| 243 |
style_selection,
|
| 244 |
randomize_seed,
|
| 245 |
use_turbo,
|
| 246 |
+
use_flash,
|
| 247 |
],
|
| 248 |
outputs=[result, seed],
|
| 249 |
api_name="run",
|