Skip to content

Commit d6a61ab

Browse files
committed
cleanup
2 parents 9f7dec7 + bdd7135 commit d6a61ab

11 files changed

+300
-357
lines changed

localizations/zh_CN.json

+27-8
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,13 @@
292292
"[wiki]": "[wiki文档]",
293293
"Embedding": "Embedding",
294294
"Embedding Learning rate": "Embedding 学习率",
295+
"Gradient accumulation steps": "梯度累计步数",
296+
"Shuffle tags by ',' when creating prompts.": "创建提示时按“,”打乱标签。",
297+
"Drop out tags when creating prompts.": "创建提示时删除标签。",
298+
"Choose latent sampling method": "选择隐采样方法",
295299
"Hypernetwork Learning rate": "Hypernetwork 学习率",
300+
"Select activation function of hypernetwork. Recommended : Swish / Linear(none)": "选择 Hypernetwork 的激活函数,推荐Swish / Linear(none)",
301+
"Select Layer weights initialization. Recommended: Kaiming for relu-like, Xavier for sigmoid-like, Normal otherwise": "选择图层权重初始化。 推荐:Kaiming 用于 relu-like,Xavier 用于 sigmoid-like,否则为 Normal",
296302
"Dataset directory": "数据集目录",
297303
"Log directory": "日志目录",
298304
"Prompt template file": "提示词模版文件",
@@ -625,17 +631,11 @@
625631
"Train settings": "训练设置",
626632
"Train an hypernetwork; you must specify a directory with a set of 1:1 ratio images": "训练 hypernetwork; 必须指定一组具有 1:1 比例图像的目录",
627633
"Hypernetwork settings": "Hypernetwork 设置",
628-
"Sign Options": "登陆选项",
629-
"Sign In": "登入",
630-
"Sign Up": "注册",
631-
"Sign Out": "登出",
632634
"Username": "用户名",
633635
"Password": "密码",
634-
"Email": "电子邮箱",
635-
"Mismatched username/password or not existed username": "用户名/密码不匹配或用户不存在",
636-
"Signup failed, please check and retry again": "注册失败,请检查后并重试",
637-
"Update failed, please check and retry again": "更新失败,请检查后并重试",
636+
"Options": "选项",
638637
"Output": "输出",
638+
"User management (Only available for admin user)": "用户管理 (仅管理员用户可用)",
639639
"Images S3 URI": "图像 S3 位置",
640640
"Models S3 URI": "模型 S3 位置",
641641
"Instance type": "实例类型",
@@ -754,6 +754,25 @@
754754
"Sample CFG Scale": "采样扩散度",
755755
"Sample Steps": "采样步数",
756756
"Cancel": "取消",
757+
"Invert colors if your image has white background.": "如果您的图像有白色背景,请反转颜色。 ",
758+
"Change your brush width to make it thinner if you want to draw something.": "如果你想画东西,改变你的画笔宽度让它更细。",
759+
"Enable": "启用",
760+
"Invert Input Color": "反转输入颜色",
761+
"RGB to BGR": "RGB 转为 BGR",
762+
"Low VRAM": "低 VRAM",
763+
"Guess Mode": "猜测模式",
764+
"Preprocessor": "预处理器",
765+
"Weight": "权重",
766+
"Guidance strength (T)": "引导强度 (T)",
767+
"Resize Mode": "调整模式",
768+
"Envelope (Outer Fit)": "信封(外部适配)",
769+
"Scale to Fit (Inner Fit)": "缩放以适合 (内部适配)",
770+
"Just Resize": "调整大小",
771+
"Canvas Width": "画布宽度",
772+
"Canvas Height": "画布高度",
773+
"Create blank canvas": "创建空白画布",
774+
"Preview annotator result": "预览标注结果",
775+
"Hide annotator result": "隐藏标注结果",
757776

758777
"--------": "--------"
759778
}

localizations/zh_TW.json

+26-4
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,12 @@
303303
"[wiki]": "[wiki文件]",
304304
"Embedding": "Embedding",
305305
"Embedding Learning rate": "Embedding 學習率",
306-
"Hypernetwork Learning rate": "超網路(Hypernetwork)學習率",
306+
"Gradient accumulation steps": "梯度累計步數",
307+
"Shuffle tags by ',' when creating prompts.": "創建提示時按“,”打亂標籤。",
308+
"Drop out tags when creating prompts.": "創建提示時刪除標籤。",
309+
"Choose latent sampling method": "選擇隱採樣方法",
310+
"Hypernetwork Learning rate": "Hypernetwork 學習率",
311+
"Select activation function of hypernetwork. Recommended : Swish / Linear(none)": "選擇 Hypernetwork 的激活函數,推薦Swish / Linear(none)",
307312
"Learning rate": "學習率",
308313
"Dataset directory": "資料集目錄",
309314
"Log directory": "日誌目錄",
@@ -338,7 +343,6 @@
338343
"End Page": "尾頁",
339344
"number of images to delete consecutively next": "接下來要連續刪除的圖像數",
340345
"delete next": "刪除下一張",
341-
"Delete": "刪除",
342346
"sort by": "排序方式",
343347
"path name": "路徑名",
344348
"date": "日期",
@@ -489,7 +493,6 @@
489493
"Check for updates": "檢查更新",
490494
"Extension": "擴充",
491495
"URL": "網址",
492-
"Update": "更新",
493496
"a1111-sd-webui-tagcomplete": "標記自動補全",
494497
"unknown": "未知",
495498
"deforum-for-automatic1111-webui": "Deforum",
@@ -744,6 +747,25 @@
744747
"Sample CFG Scale": "採樣擴散度",
745748
"Sample Steps": "採樣步數",
746749
"Cancel": "取消",
747-
750+
"Invert colors if your image has white background.": "如果您的圖像有白色背景,請反轉顏色。 ",
751+
"Change your brush width to make it thinner if you want to draw something.": "如果你想畫東西,改變你的畫筆寬度讓它更細。",
752+
"Enable": "啟用",
753+
"Invert Input Color": "反轉輸入顏色",
754+
"RGB to BGR": "RGB 轉為 BGR",
755+
"Low VRAM": "低 VRAM",
756+
"Guess Mode": "猜測模式",
757+
"Preprocessor": "預處理器",
758+
"Weight": "權重",
759+
"Guidance strength (T)": "引導強度 (T)",
760+
"Resize Mode": "調整模式",
761+
"Envelope (Outer Fit)": "信封(外部適配)",
762+
"Scale to Fit (Inner Fit)": "縮放以適合 (內部適配)",
763+
"Just Resize": "調整大小",
764+
"Canvas Width": "畫布寬度",
765+
"Canvas Height": "畫布高度",
766+
"Create blank canvas": "創建空白畫布",
767+
"Preview annotator result": "預覽標註結果",
768+
"Hide annotator result": "隱藏標註結果",
769+
748770
"--------": "--------"
749771
}

modules/call_queue.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from PIL import Image, ImageOps, ImageFilter, ImageEnhance, ImageChops
1919

2020
from modules import shared
21+
import gradio as gr
2122

2223
queue_lock = threading.Lock()
2324

@@ -31,7 +32,7 @@ def f(*args, **kwargs):
3132

3233
return f
3334

34-
def wrap_gradio_gpu_call(func, extra_outputs=None):
35+
def wrap_gradio_gpu_call(func, extra_outputs=None):
3536
def encode_image_to_base64(image):
3637
if isinstance(image, bytes):
3738
encoded_string = base64.b64encode(image)
@@ -408,19 +409,16 @@ def sagemaker_inference(task, infer, username, sagemaker_endpoint, *args, **kwar
408409
info = processed['html_info']
409410
return images, modules.ui.plaintext_to_html(info), ''
410411

411-
def f(*args, **kwargs):
412+
def f(username, *args, **kwargs):
412413
if cmd_opts.pureui and func == modules.txt2img.txt2img:
413-
username = args[len(args) - 2]
414414
sagemaker_endpoint = args[len(args) -1]
415415
args = args[:-2]
416416
res = sagemaker_inference('text-to-image', 'sync', username, sagemaker_endpoint, *args, **kwargs)
417417
elif cmd_opts.pureui and func == modules.img2img.img2img:
418-
username = args[len(args) - 2]
419418
sagemaker_endpoint = args[len(args) -1]
420419
args = args[:-2]
421420
res = sagemaker_inference('image-to-image', 'sync', username, sagemaker_endpoint, *args, **kwargs)
422421
elif cmd_opts.pureui and func == modules.extras.run_extras:
423-
username = args[len(args) - 2]
424422
sagemaker_endpoint = args[len(args) -1]
425423
args = args[:-2]
426424
res = sagemaker_inference('extras', 'sync', username, sagemaker_endpoint, *args, **kwargs)
@@ -436,14 +434,26 @@ def f(*args, **kwargs):
436434

437435

438436
def wrap_gradio_call(func, extra_outputs=None, add_stats=False):
439-
def f(*args, extra_outputs_array=extra_outputs, **kwargs):
437+
def f(request: gr.Request, *args, extra_outputs_array=extra_outputs, **kwargs):
438+
tokens = shared.demo.server_app.tokens
439+
cookies = request.headers['cookie'].split('; ')
440+
access_token = None
441+
for cookie in cookies:
442+
if cookie.startswith('access-token'):
443+
access_token = cookie[len('access-token=') : ]
444+
break
445+
username = tokens[access_token]
446+
440447
run_memmon = shared.opts.memmon_poll_rate > 0 and not shared.mem_mon.disabled and add_stats
441448
if run_memmon:
442449
shared.mem_mon.monitor()
443450
t = time.perf_counter()
444451

445452
try:
446-
res = list(func(*args, **kwargs))
453+
if func.__name__ == 'f':
454+
res = list(func(username, *args, **kwargs))
455+
else:
456+
res = list(func(*args, **kwargs))
447457
except Exception as e:
448458
# When printing out our debug argument list, do not print out more than a MB of text
449459
max_debug_str_len = 131072 # (1024*1024)/8

modules/sd_models.py

+21-18
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,27 @@ def modeltitle(path, shorthash):
7979
return f'{name} [{shorthash}]', shortname
8080

8181
if shared.cmd_opts.pureui:
82-
params = {
83-
'module': 'Stable-diffusion', 'endpoint_name': sagemaker_endpoint
84-
}
85-
response = requests.get(url=f'{api_endpoint}/sd/models', params=params)
86-
if response.status_code == 200:
87-
model_list = json.loads(response.text)
88-
89-
for model in model_list:
90-
h = model['hash']
91-
filename = model['filename']
92-
title = model['title']
93-
short_model_name = model['model_name']
94-
config = model['config']
95-
96-
if 'sd_model_checkpoint' not in shared.opts.data:
97-
shared.opts.data['sd_model_checkpoint'] = title
98-
99-
checkpoints_list[title] = CheckpointInfo(filename, title, h, short_model_name, config)
82+
if sagemaker_endpoint:
83+
params = {
84+
'module': 'Stable-diffusion', 'endpoint_name': sagemaker_endpoint
85+
}
86+
response = requests.get(url=f'{api_endpoint}/sd/models', params=params)
87+
if response.status_code == 200:
88+
model_list = json.loads(response.text)
89+
90+
for model in model_list:
91+
h = model['hash']
92+
filename = model['filename']
93+
title = model['title']
94+
short_model_name = model['model_name']
95+
config = model['config']
96+
97+
if 'sd_model_checkpoint' not in shared.opts.data:
98+
shared.opts.data['sd_model_checkpoint'] = title
99+
100+
checkpoints_list[title] = CheckpointInfo(filename, title, h, short_model_name, config)
101+
else:
102+
print(response.text)
100103

101104
sd_model_checkpoint = shared.opts.data['sd_model_checkpoint']
102105
if sd_model_checkpoint and sd_model_checkpoint in checkpoints_list:

modules/shared.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
sagemaker_endpoint_component = None
145145
sd_model_checkpoint_component = None
146146
create_train_dreambooth_component = None
147+
username = ''
147148

148149
response = requests.get(url=f'{api_endpoint}/sd/industrialmodel')
149150
if response.status_code == 200:
@@ -301,7 +302,9 @@ def list_checkpoint_tiles():
301302

302303
def refresh_checkpoints(sagemaker_endpoint=None):
303304
import modules.sd_models
304-
return modules.sd_models.list_models(sagemaker_endpoint)
305+
modules.sd_models.list_models(sagemaker_endpoint)
306+
checkpoints = modules.sd_models.checkpoints_list
307+
return checkpoints
305308

306309

307310
def list_samplers():
@@ -320,7 +323,7 @@ def list_sagemaker_endpoints():
320323

321324
return sagemaker_endpoints
322325

323-
def refresh_sagemaker_endpoints(username=None):
326+
def refresh_sagemaker_endpoints(username):
324327
global industrial_model, api_endpoint, sagemaker_endpoints
325328

326329
sagemaker_endpoints = []

0 commit comments

Comments
 (0)