diff --git a/BaiHu/Backup/doTaskWithMJ.py b/BaiHu/Backup/doTaskWithMJ.py index f0762753..f32b7e80 100644 --- a/BaiHu/Backup/doTaskWithMJ.py +++ b/BaiHu/Backup/doTaskWithMJ.py @@ -5,7 +5,7 @@ from urllib.parse import urlparse from tqdm import tqdm from Util import ConfigUtil from Util.AesUtil import * -from Util.ComfyUIUtil import * +from Util.SDUtil import * from Util.CommonUtil import * from Util.Logger import Logger from Util.OssUtil import uploadOss diff --git a/BaiHu/Doc/如何激活API重新启动SD.md b/BaiHu/Doc/如何激活API重新启动SD.md new file mode 100644 index 00000000..e0be6323 --- /dev/null +++ b/BaiHu/Doc/如何激活API重新启动SD.md @@ -0,0 +1,19 @@ + +https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/14135 +add to args in webui-user.bat --api-server-stop to activate endpoints: +``` +/sdapi/v1/server-kill +/sdapi/v1/server-restart +/sdapi/v1/server-stop +``` + +# 添加启动参数 +def main(): + import sys + # --api-server-stop + #sys.argv.append("--no-half") + sys.argv.append("--api-server-stop") + + if args.dump_sysinfo: + filename = launch_utils.dump_sysinfo() + diff --git a/BaiHu/Image/45/1.png b/BaiHu/Image/45/1.png new file mode 100644 index 00000000..7ea86843 Binary files /dev/null and b/BaiHu/Image/45/1.png differ diff --git a/BaiHu/Image/45/2.png b/BaiHu/Image/45/2.png new file mode 100644 index 00000000..e3fb5697 Binary files /dev/null and b/BaiHu/Image/45/2.png differ diff --git a/BaiHu/Image/45/3.png b/BaiHu/Image/45/3.png new file mode 100644 index 00000000..9892e769 Binary files /dev/null and b/BaiHu/Image/45/3.png differ diff --git a/BaiHu/Image/45/4.png b/BaiHu/Image/45/4.png new file mode 100644 index 00000000..5e28b21c Binary files /dev/null and b/BaiHu/Image/45/4.png differ diff --git a/BaiHu/Image/45/5.png b/BaiHu/Image/45/5.png new file mode 100644 index 00000000..0ab7871c Binary files /dev/null and b/BaiHu/Image/45/5.png differ diff --git a/BaiHu/JSON/45_1.json b/BaiHu/JSON/45_1.json new file mode 100644 index 00000000..0c1832a4 --- /dev/null +++ b/BaiHu/JSON/45_1.json @@ -0,0 +1,43 @@ +{ + "override_settings": { + "sd_model_checkpoint": "C-2.5D-Eleventhversion-Q版_v11.0.safetensors [a635ab0dee]", + "sd_vae": "Automatic" + }, + "prompt": "chibi,1 girl,gray hair,blue eyes,bucket hat,with backpack,anxious,forest,Astral,((night) ),(running),(((chasing fireflies with a bug net))),The light of the firefly.(beautiful detailed face),(beautiful detailed eyes),.small backpac.,,", + "negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,cleavage,", + "steps": 23, + "sampler_name": "DPM++ 2M Karras", + "width": 768, + "height": 1152, + "batch_size": 1, + "n_iter": 1, + "seed": 1, + "cfg_scale": 6, + "CLIP_stop_at_last_layers": 2, + "init_images": [ + "string" + ], + "restore_faces": false, + "enable_hr": true, + "denoising_strength": 0.5, + "alwayson_scripts": { + "ControlNet": { + "args": [ + { + "enabled": true, + "model": "ip-adapter-faceid-plusv2_sd15 [6e14fc1a]", + "module": "ip-adapter_face_id_plus", + "weight": 1, + "resize_mode": "Crop and Resize", + "guidance_start": 0, + "guidance_end": 1, + "pixel_perfect": true, + "processor_res": 512, + "save_detected_map": true, + "input_image": "string", + "control_mode": "My prompt is more important" + } + ] + } + } +} \ No newline at end of file diff --git a/BaiHu/JSON/45_2.json b/BaiHu/JSON/45_2.json new file mode 100644 index 00000000..48802172 --- /dev/null +++ b/BaiHu/JSON/45_2.json @@ -0,0 +1,43 @@ +{ + "override_settings": { + "sd_model_checkpoint": "C-2.5D-Eleventhversion-Q版_v11.0.safetensors [a635ab0dee]", + "sd_vae": "Automatic" + }, + "prompt": "chibi,1girl,solo,long hair,cute,smile,open mouth,flower,outdoors,playing guitar,music,beret,holding guitar,jacket,shirt,shorthair,cherry blossoms,,", + "negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,cleavage,", + "steps": 23, + "sampler_name": "DPM++ 2M Karras", + "width": 768, + "height": 1152, + "batch_size": 1, + "n_iter": 1, + "seed": 1, + "cfg_scale": 6, + "CLIP_stop_at_last_layers": 2, + "init_images": [ + "string" + ], + "restore_faces": false, + "enable_hr": true, + "denoising_strength": 0.5, + "alwayson_scripts": { + "ControlNet": { + "args": [ + { + "enabled": true, + "model": "ip-adapter-faceid-plusv2_sd15 [6e14fc1a]", + "module": "ip-adapter_face_id_plus", + "weight": 1, + "resize_mode": "Crop and Resize", + "guidance_start": 0, + "guidance_end": 1, + "pixel_perfect": true, + "processor_res": 512, + "save_detected_map": true, + "input_image": "string", + "control_mode": "My prompt is more important" + } + ] + } + } +} \ No newline at end of file diff --git a/BaiHu/JSON/45_3.json b/BaiHu/JSON/45_3.json new file mode 100644 index 00000000..118c88c7 --- /dev/null +++ b/BaiHu/JSON/45_3.json @@ -0,0 +1,43 @@ +{ + "override_settings": { + "sd_model_checkpoint": "C-2.5D-Eleventhversion-Q版_v11.0.safetensors [a635ab0dee]", + "sd_vae": "Automatic" + }, + "prompt": "chibi, 1girl, solo, long hair, white shirt, jeans, sitting, ndoors,,", + "negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,cleavage,", + "steps": 23, + "sampler_name": "DPM++ 2M Karras", + "width": 768, + "height": 1152, + "batch_size": 1, + "n_iter": 1, + "seed": 1, + "cfg_scale": 6, + "CLIP_stop_at_last_layers": 2, + "init_images": [ + "string" + ], + "restore_faces": false, + "enable_hr": true, + "denoising_strength": 0.5, + "alwayson_scripts": { + "ControlNet": { + "args": [ + { + "enabled": true, + "model": "ip-adapter-faceid-plusv2_sd15 [6e14fc1a]", + "module": "ip-adapter_face_id_plus", + "weight": 1, + "resize_mode": "Crop and Resize", + "guidance_start": 0, + "guidance_end": 1, + "pixel_perfect": true, + "processor_res": 512, + "save_detected_map": true, + "input_image": "string", + "control_mode": "My prompt is more important" + } + ] + } + } +} \ No newline at end of file diff --git a/BaiHu/JSON/45_4.json b/BaiHu/JSON/45_4.json new file mode 100644 index 00000000..7dd35b17 --- /dev/null +++ b/BaiHu/JSON/45_4.json @@ -0,0 +1,43 @@ +{ + "override_settings": { + "sd_model_checkpoint": "C-2.5D-Eleventhversion-Q版_v11.0.safetensors [a635ab0dee]", + "sd_vae": "Automatic" + }, + "prompt": "chibi,1girl,solo,long hair,mecha,full body,", + "negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,cleavage,", + "steps": 23, + "sampler_name": "DPM++ 2M Karras", + "width": 768, + "height": 1152, + "batch_size": 1, + "n_iter": 1, + "seed": 1, + "cfg_scale": 6, + "CLIP_stop_at_last_layers": 2, + "init_images": [ + "string" + ], + "restore_faces": false, + "enable_hr": true, + "denoising_strength": 0.5, + "alwayson_scripts": { + "ControlNet": { + "args": [ + { + "enabled": true, + "model": "ip-adapter-faceid-plusv2_sd15 [6e14fc1a]", + "module": "ip-adapter_face_id_plus", + "weight": 1, + "resize_mode": "Crop and Resize", + "guidance_start": 0, + "guidance_end": 1, + "pixel_perfect": true, + "processor_res": 512, + "save_detected_map": true, + "input_image": "string", + "control_mode": "My prompt is more important" + } + ] + } + } +} \ No newline at end of file diff --git a/BaiHu/JSON/45_5.json b/BaiHu/JSON/45_5.json new file mode 100644 index 00000000..d4fd46f0 --- /dev/null +++ b/BaiHu/JSON/45_5.json @@ -0,0 +1,43 @@ +{ + "override_settings": { + "sd_model_checkpoint": "C-2.5D-Eleventhversion-Q版_v11.0.safetensors [a635ab0dee]", + "sd_vae": "Automatic" + }, + "prompt": "MakotoShinkaiStyle,a cute little girl sitting on the grass,looking up at the blue night sky,the sky and grass as the background,the central composition,evening,color dark soft,style,cartoonish,the best quality,,", + "negative_prompt": "NSFW,blurry,low quality,watermark,monochrome,badhandv4,easynegative,ng_deepnegative_v1_75t,bad proportions,mutated hands and fingers,poorly drawn face,extra limb,missing limb,malformed limbs,disconnected limbs,ugly,floating limbs,extra legs,mutation,bad body,long neck,cross-eyed,text,cleavage,", + "steps": 23, + "sampler_name": "DPM++ 2M Karras", + "width": 768, + "height": 1152, + "batch_size": 1, + "n_iter": 1, + "seed": 1, + "cfg_scale": 6, + "CLIP_stop_at_last_layers": 2, + "init_images": [ + "string" + ], + "restore_faces": false, + "enable_hr": true, + "denoising_strength": 0.5, + "alwayson_scripts": { + "ControlNet": { + "args": [ + { + "enabled": true, + "model": "ip-adapter-faceid-plusv2_sd15 [6e14fc1a]", + "module": "ip-adapter_face_id_plus", + "weight": 1, + "resize_mode": "Crop and Resize", + "guidance_start": 0, + "guidance_end": 1, + "pixel_perfect": true, + "processor_res": 512, + "save_detected_map": true, + "input_image": "string", + "control_mode": "My prompt is more important" + } + ] + } + } +} \ No newline at end of file diff --git a/BaiHu/Test/ComfyUI.py b/BaiHu/Test/ComfyUI.py index e84567e9..4ec51076 100644 --- a/BaiHu/Test/ComfyUI.py +++ b/BaiHu/Test/ComfyUI.py @@ -7,7 +7,7 @@ # 参考:https://blog.csdn.net/it_is_arlon/article/details/130359239 import os -from Util.ComfyUIUtil import * +from Util.SDUtil import * from Util import ConfigUtil diff --git a/BaiHu/Test/Test16.py b/BaiHu/Test/Test16.py index f50ca3a0..b5268bb2 100644 --- a/BaiHu/Test/Test16.py +++ b/BaiHu/Test/Test16.py @@ -1,7 +1,7 @@ import os from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * from natsort import natsorted def C16(prompt_data, img, source_code, target_code, model_id, user_id): diff --git a/BaiHu/Test/Test19.py b/BaiHu/Test/Test19.py index 61f572e3..28c35f08 100644 --- a/BaiHu/Test/Test19.py +++ b/BaiHu/Test/Test19.py @@ -1,7 +1,7 @@ import os from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * def C19(prompt_data, img, source_code, target_code): diff --git a/BaiHu/Test/Test20.py b/BaiHu/Test/Test20.py index 99f7f9a6..57a5de84 100644 --- a/BaiHu/Test/Test20.py +++ b/BaiHu/Test/Test20.py @@ -1,7 +1,7 @@ import os from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * def C19(prompt_data, img, source_code, target_code): diff --git a/BaiHu/Test/Test21.py b/BaiHu/Test/Test21.py index dd287da9..6e4b78f2 100644 --- a/BaiHu/Test/Test21.py +++ b/BaiHu/Test/Test21.py @@ -2,7 +2,7 @@ import os import random from Util.PngUtil import * from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * from Util.CommonUtil import * from Util.OssUtil import uploadOss diff --git a/BaiHu/Test/Test22.py b/BaiHu/Test/Test22.py index de4da451..bd79cbc7 100644 --- a/BaiHu/Test/Test22.py +++ b/BaiHu/Test/Test22.py @@ -1,7 +1,7 @@ import os from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * def C22(prompt_data, img, source_code, target_code, idx): diff --git a/BaiHu/Test/Test22_New.py b/BaiHu/Test/Test22_New.py index 362e155d..d109d01d 100644 --- a/BaiHu/Test/Test22_New.py +++ b/BaiHu/Test/Test22_New.py @@ -1,7 +1,7 @@ import os from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * def C22(prompt_data, img): diff --git a/BaiHu/Test/Test23.py b/BaiHu/Test/Test23.py index ba463861..457d4c2f 100644 --- a/BaiHu/Test/Test23.py +++ b/BaiHu/Test/Test23.py @@ -1,7 +1,7 @@ import os from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * def C23(prompt_data, img, source_code, target_code): diff --git a/BaiHu/Test/Test24.py b/BaiHu/Test/Test24.py index 6ef49ceb..0f696d0c 100644 --- a/BaiHu/Test/Test24.py +++ b/BaiHu/Test/Test24.py @@ -1,7 +1,7 @@ import os from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * def C24(prompt_data, img, source_code, target_code): diff --git a/BaiHu/Test/Test25.py b/BaiHu/Test/Test25.py index deed5063..cc6e76a8 100644 --- a/BaiHu/Test/Test25.py +++ b/BaiHu/Test/Test25.py @@ -1,7 +1,7 @@ import os from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * import random diff --git a/BaiHu/Test/Test26.py b/BaiHu/Test/Test26.py index 382d629c..a373c7f2 100644 --- a/BaiHu/Test/Test26.py +++ b/BaiHu/Test/Test26.py @@ -1,7 +1,7 @@ import os from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * import random diff --git a/BaiHu/Test/Test27.py b/BaiHu/Test/Test27.py index 6f3e4243..9e43ac21 100644 --- a/BaiHu/Test/Test27.py +++ b/BaiHu/Test/Test27.py @@ -1,7 +1,7 @@ import os from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * import random diff --git a/BaiHu/Tools/ShlStudentCute.py b/BaiHu/Tools/ShlStudentCute.py index 3fd3aa03..a2307b13 100644 --- a/BaiHu/Tools/ShlStudentCute.py +++ b/BaiHu/Tools/ShlStudentCute.py @@ -2,7 +2,7 @@ import os import random from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * from Util.CommonUtil import * diff --git a/BaiHu/Tools/ShlStudentDtt.py b/BaiHu/Tools/ShlStudentDtt.py index 382af91a..96cc3435 100644 --- a/BaiHu/Tools/ShlStudentDtt.py +++ b/BaiHu/Tools/ShlStudentDtt.py @@ -2,7 +2,7 @@ import os import random from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * from Util.CommonUtil import * diff --git a/BaiHu/Tools/ShlStudentJiJia.py b/BaiHu/Tools/ShlStudentJiJia.py index 7546068a..8639943c 100644 --- a/BaiHu/Tools/ShlStudentJiJia.py +++ b/BaiHu/Tools/ShlStudentJiJia.py @@ -2,7 +2,7 @@ import os import random from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * from Util.CommonUtil import * diff --git a/BaiHu/Tools/TestComfyUIApi.py b/BaiHu/Tools/TestComfyUIApi.py index 41ffb1be..5acf8cdf 100644 --- a/BaiHu/Tools/TestComfyUIApi.py +++ b/BaiHu/Tools/TestComfyUIApi.py @@ -1,5 +1,5 @@ from Util import ConfigUtil -from Util.ComfyUIUtil import * +from Util.SDUtil import * # 打开配置文件 config = ConfigUtil.getConfig() @@ -14,8 +14,14 @@ info = get_comfyui_used(comfyui_address) print(info) # 获取使显存数量 -get_webui_used(webui_address) -# 清理缓存 -clear_webui_cache(webui_address) -# 获取使显存数量 -get_webui_used(webui_address) +total, used = get_webui_used(webui_address) + +# 显卡显存占用超过20GB +if float(used) > 20: + print("发现显存占用高达" + used + "GB,准备重启SD...") + # 重新启动一下SD + restart_server(webui_address) + # 休息2分钟以保证SD重启完成 + time.sleep(2 * 60) +else: + print("显存占用正常,无法重新启动SD!") diff --git a/BaiHu/Tools/addModel.py b/BaiHu/Tools/addModel.py index ddceba33..94f6cac5 100644 --- a/BaiHu/Tools/addModel.py +++ b/BaiHu/Tools/addModel.py @@ -6,10 +6,10 @@ from Util.PgUtil import * sql = "INSERT INTO t_hy_model(model_id,model_name,memo,star,update_time,img_count,b_use,sort_id,model_type_id,style_id,is_cover) VALUES (%s,%s, %s,%s,now(),%s,1,1,%s,%s,%s);" # 模型编号 -model_id = 44 +model_id = 45 # 模型名称 -model_name = '黏土世界' +model_name = '治愈风二次元' # 提示信息 memo = '1、请上传正面半身照。; 2、确保脸部无遮挡;3、图片要求不小于1.5MB(正常手机拍照即可)' diff --git a/BaiHu/Util/ComfyUIUtil.py b/BaiHu/Util/SDUtil.py similarity index 94% rename from BaiHu/Util/ComfyUIUtil.py rename to BaiHu/Util/SDUtil.py index e3df3b0d..8665b2d4 100644 --- a/BaiHu/Util/ComfyUIUtil.py +++ b/BaiHu/Util/SDUtil.py @@ -1,4 +1,3 @@ -import json import os.path import time import urllib.parse @@ -180,12 +179,13 @@ def get_webui_used(webui_server): print("显存:" + total + "GB,已使用:" + used + "GB,使用率:" + str(used_lv) + '%') else: print("调用集成的获取显卡显存代码失败!") + return total, used # 清理webui的缓存 -def clear_webui_cache(webui_server): +def clear_webui_cache(webui_address): # webui 服务器地址 - empty_cache_url = "http://{}/sdapi/v1/empty_cache".format(webui_server) + empty_cache_url = "http://{}/sdapi/v1/empty_cache".format(webui_address) res = submit_post(empty_cache_url, None) if res.status_code == 200: jo = json.loads(res.text) @@ -195,3 +195,9 @@ def clear_webui_cache(webui_server): print("显存清理失败!") else: print("调用集成的清理显卡显存代码失败!") + + +# 重新启动SD +def restart_server(webui_address): + server_restart_url = "http://{}/sdapi/v1/server-restart".format(webui_address) + submit_post(server_restart_url, None) diff --git a/BaiHu/Util/__pycache__/ComfyUIUtil.cpython-310.pyc b/BaiHu/Util/__pycache__/SDUtil.cpython-310.pyc similarity index 76% rename from BaiHu/Util/__pycache__/ComfyUIUtil.cpython-310.pyc rename to BaiHu/Util/__pycache__/SDUtil.cpython-310.pyc index 8c60091f..48655d96 100644 Binary files a/BaiHu/Util/__pycache__/ComfyUIUtil.cpython-310.pyc and b/BaiHu/Util/__pycache__/SDUtil.cpython-310.pyc differ diff --git a/BaiHu/doTask.py b/BaiHu/doTask.py index 49983378..e80949d8 100644 --- a/BaiHu/doTask.py +++ b/BaiHu/doTask.py @@ -5,7 +5,7 @@ from urllib.parse import urlparse from Util import ConfigUtil from Util.AesUtil import * -from Util.ComfyUIUtil import * +from Util.SDUtil import * from Util.CommonUtil import * from Util.OssUtil import uploadOss from Util.PngUtil import * @@ -33,8 +33,8 @@ def webui_txt_2_img(model_id, json_data, input_image, target_folder): # 图片 args = json_data['alwayson_scripts']['ControlNet']['args'] - #pretty_json = json.dumps(json_data, indent=4,ensure_ascii=False) - #print(pretty_json) + # pretty_json = json.dumps(json_data, indent=4,ensure_ascii=False) + # print(pretty_json) pose_image = json_data['pose_image'] args[0]['input_image'] = encode_image(input_image[0]) @@ -143,7 +143,6 @@ def download_image(image_url, file_path): printf('图片下载失败,状态码:' + str(response.status_code)) - # 根据输入的图片集合,填充到 def fill_input(prompt_data, file_array): # 是不是不存在配置节 @@ -329,7 +328,7 @@ if __name__ == '__main__': # 清理SD缓存 clear_webui_cache(webui_address) - get_webui_used(webui_address) + total, used = get_webui_used(webui_address) # 清理GPU缓存 clear_comfyui_cache(comfyui_address)