Spaces:
Running
Running
k-l-lambda
commited on
Commit
·
9933c91
1
Parent(s):
5975e3b
app.py: refined arguments preprocessing.
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ from io import BytesIO
|
|
8 |
import PIL.Image
|
9 |
from typing import Tuple
|
10 |
from novita_client import NovitaClient, V3TaskResponseStatus
|
11 |
-
from time import
|
12 |
|
13 |
from style_template import styles
|
14 |
|
@@ -118,6 +118,8 @@ CONTROLNET_DICT = dict(
|
|
118 |
},
|
119 |
)
|
120 |
|
|
|
|
|
121 |
|
122 |
|
123 |
def get_novita_client (novita_key):
|
@@ -242,12 +244,13 @@ def generate_image (
|
|
242 |
raise gr.Error(f'Cannot find any input face image! Please refer to step 1️⃣')
|
243 |
|
244 |
#print('novita_key:', novita_key1)
|
245 |
-
print('face_image_path:', face_image_path)
|
246 |
if not novita_key1:
|
247 |
raise gr.Error(f'Please input your Novita Key!')
|
248 |
try:
|
249 |
client = get_novita_client(novita_key1)
|
250 |
prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
|
|
251 |
#print('prompt:', prompt)
|
252 |
#print('negative_prompt:', negative_prompt)
|
253 |
#print('seed:', seed)
|
@@ -296,11 +299,16 @@ def generate_image (
|
|
296 |
|
297 |
print('task_id:', res['task_id'])
|
298 |
def progress (x):
|
299 |
-
|
|
|
|
|
|
|
|
|
300 |
final_res = client.wait_for_task_v3(res['task_id'], callback=progress)
|
301 |
if final_res is None or final_res.task.status == V3TaskResponseStatus.TASK_STATUS_FAILED:
|
302 |
raise RuntimeError(f'Novita task failed: {final_res and final_res.task.status}')
|
303 |
print('status:', final_res.task.status)
|
|
|
304 |
|
305 |
final_res.download_images()
|
306 |
except Exception as e:
|
@@ -452,8 +460,8 @@ with gr.Blocks(css=css) as demo:
|
|
452 |
)
|
453 |
guidance_scale = gr.Slider(
|
454 |
label='Guidance scale',
|
455 |
-
minimum=
|
456 |
-
maximum=
|
457 |
step=0.1,
|
458 |
value=0.0 if enable_lcm_arg else 5.0,
|
459 |
)
|
|
|
8 |
import PIL.Image
|
9 |
from typing import Tuple
|
10 |
from novita_client import NovitaClient, V3TaskResponseStatus
|
11 |
+
from time import time
|
12 |
|
13 |
from style_template import styles
|
14 |
|
|
|
118 |
},
|
119 |
)
|
120 |
|
121 |
+
last_check = 0
|
122 |
+
|
123 |
|
124 |
|
125 |
def get_novita_client (novita_key):
|
|
|
244 |
raise gr.Error(f'Cannot find any input face image! Please refer to step 1️⃣')
|
245 |
|
246 |
#print('novita_key:', novita_key1)
|
247 |
+
#print('face_image_path:', face_image_path)
|
248 |
if not novita_key1:
|
249 |
raise gr.Error(f'Please input your Novita Key!')
|
250 |
try:
|
251 |
client = get_novita_client(novita_key1)
|
252 |
prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
253 |
+
prompt = prompt[:1024]
|
254 |
#print('prompt:', prompt)
|
255 |
#print('negative_prompt:', negative_prompt)
|
256 |
#print('seed:', seed)
|
|
|
299 |
|
300 |
print('task_id:', res['task_id'])
|
301 |
def progress (x):
|
302 |
+
global last_check
|
303 |
+
t = time()
|
304 |
+
if t > last_check + 5:
|
305 |
+
last_check = t
|
306 |
+
print('progress:', t, x.task.status)
|
307 |
final_res = client.wait_for_task_v3(res['task_id'], callback=progress)
|
308 |
if final_res is None or final_res.task.status == V3TaskResponseStatus.TASK_STATUS_FAILED:
|
309 |
raise RuntimeError(f'Novita task failed: {final_res and final_res.task.status}')
|
310 |
print('status:', final_res.task.status)
|
311 |
+
print('returned images:', final_res.images)
|
312 |
|
313 |
final_res.download_images()
|
314 |
except Exception as e:
|
|
|
460 |
)
|
461 |
guidance_scale = gr.Slider(
|
462 |
label='Guidance scale',
|
463 |
+
minimum=1.,
|
464 |
+
maximum=30.0,
|
465 |
step=0.1,
|
466 |
value=0.0 if enable_lcm_arg else 5.0,
|
467 |
)
|