Переглянути джерело

绘图模型添加model=2

关习习 2 тижнів тому
батько
коміт
0d98ad2b2b
3 змінених файлів з 53 додано та 25 видалено
  1. 40 19
      ai_pic.py
  2. 11 4
      main.py
  3. 2 2
      p2p_ll.json

+ 40 - 19
ai_pic.py

@@ -171,30 +171,51 @@ def story_start(prompt):
     start_paint(id, data)
     return get_images_from_filenames(get_websocket_data(id))
 
-def story_start_p2p(qq):
+def story_start_p2p(qq, model=1):
     """
     调用p2p的任务下发开关,传入qq号,自动根据user文件夹下的用户名搜索头像来变身
     用户头像存储路径默认user文件夹
     """
-    with open('p2p.json', 'r', encoding='utf-8') as file:
-        data = json.load(file)
-    data['49']['inputs']["directory"] = f"{file_path}/user/{qq}/"
-    data["43"]["inputs"]["seed"] = random.randint(1, 2 ** 32 - 1)
-    id = generate_instance_id()
-    start_paint(id, data)
-    return get_images_from_filenames(get_websocket_data(id))
-
-def story_start_p2p_sese(qq):
+    if model == 1:
+        with open('p2p.json', 'r', encoding='utf-8') as file:
+            data = json.load(file)
+        data['49']['inputs']["directory"] = f"{file_path}/user/{qq}/"
+        data["43"]["inputs"]["seed"] = random.randint(1, 2 ** 32 - 1)
+        id = generate_instance_id()
+        start_paint(id, data)
+        return get_images_from_filenames(get_websocket_data(id))
+    elif model == 2:
+        with open('p2p_ll.json', 'r', encoding='utf-8') as file:
+            data = json.load(file)
+        data['14']['inputs']["directory"] = f"{file_path}/user/{qq}/"
+        data["43"]["inputs"]["seed"] = random.randint(1, 2 ** 32 - 1)
+        id = generate_instance_id()
+        start_paint(id, data)
+        return get_images_from_filenames(get_websocket_data(id))
+
+
+def story_start_p2p_sese(qq, model=1):
     """
     调用p2p涩图版的任务下发开关,传入qq号,自动根据user文件夹下的用户名搜索头像来变身
     用户头像存储路径默认user文件夹
     """
-    with open('p2p.json', 'r', encoding='utf-8') as file:
-        data = json.load(file)
-    data['49']['inputs']["directory"] = f"{file_path}/user/{qq}/"
-    data["43"]["inputs"]["seed"] = random.randint(1, 2 ** 32 - 1)
-    data['3']['inputs']["text"] = "nsfw,1girl"
-    data['4']['inputs']["text"] = config_get("pro_bad_sese")
-    id = generate_instance_id()
-    start_paint(id, data)
-    return get_images_from_filenames(get_websocket_data(id))
+    if model == 1:
+        with open('p2p.json', 'r', encoding='utf-8') as file:
+            data = json.load(file)
+        data['49']['inputs']["directory"] = f"{file_path}/user/{qq}/"
+        data["43"]["inputs"]["seed"] = random.randint(1, 2 ** 32 - 1)
+        data['3']['inputs']["text"] = "nsfw,1girl"
+        data['4']['inputs']["text"] = config_get("pro_bad_sese")
+        id = generate_instance_id()
+        start_paint(id, data)
+        return get_images_from_filenames(get_websocket_data(id))
+    elif model == 2:
+        with open('p2p_ll.json', 'r', encoding='utf-8') as file:
+            data = json.load(file)
+        data['14']['inputs']["directory"] = f"{file_path}/user/{qq}/"
+        data["43"]["inputs"]["seed"] = random.randint(1, 2 ** 32 - 1)
+        data['6']['inputs']["text"] = "nsfw,1girl,best quality,masterpiece,"
+        id = generate_instance_id()
+        start_paint(id, data)
+        return get_images_from_filenames(get_websocket_data(id))
+

+ 11 - 4
main.py

@@ -161,7 +161,7 @@ def ch_stone(name):
             return stones.loc[i, 'type'] +" " + stones.loc[i, 'name'] + stone_up_on + stones.loc[i, 'stat']
     return "这里似乎没有你想找的东西喵~\n如果要查找王石,请使用/王石查询正确的王石名称,示例:\n@猫猫 /王石科隆老大\n如果不清楚王石全名,可以在[掌上波多姆]中进行模糊搜索喵"
 
-def change2setu(raw_message,group_id,user_id):
+def change2setu(raw_message,group_id,user_id, model=1):
     """
     进入变瑟图命令
     """
@@ -185,7 +185,7 @@ def change2setu(raw_message,group_id,user_id):
                 file.write(img_response.content)
             print(f'图片已保存到 {file_path}')
             send_group_message_word(group_id, "开始变身!")
-            message_id = send_group_message_pic(group_id, user_id, story_start_p2p_sese(qq))
+            message_id = send_group_message_pic(group_id, user_id, story_start_p2p_sese(qq, model))
             print(message_id)
             time.sleep(8)
             del_group_message(message_id['data']['message_id'])
@@ -195,7 +195,7 @@ def change2setu(raw_message,group_id,user_id):
     else:
         print('未找到 QQ 号')
 
-def change2girl(raw_message,group_id,user_id):
+def change2girl(raw_message,group_id,user_id, model=1):
     """
     进入变美少女命令
     """
@@ -219,7 +219,7 @@ def change2girl(raw_message,group_id,user_id):
                 file.write(img_response.content)
             print(f'图片已保存到 {file_path}')
             send_group_message_word(group_id, "开始变身!")
-            send_group_message_pic(group_id, user_id, story_start_p2p(qq))
+            send_group_message_pic(group_id, user_id, story_start_p2p(qq,model))
         except Exception as e:
             print(f'发生未知错误: {e}')
             send_group_message_word(group_id, "变身失败!")
@@ -264,11 +264,18 @@ def chat():
         # 然后根据命令优先级进入AI对话模式,在这里写入AI模块
         if str(raw_message).startswith("变美少女[CQ:at"):
             change2girl(raw_message, group_id, user_id)
+        elif str(raw_message).startswith("变美少女2[CQ:at"):
+            change2setu(raw_message, group_id, user_id, 2)
         elif str(raw_message).startswith("变瑟图[CQ:at"):
             if group_id == 637612718:
                 send_group_message_word(group_id,"本群该功能已被禁用!")
             else:
                 change2setu(raw_message, group_id, user_id)
+        elif str(raw_message).startswith("变瑟图2[CQ:at"):
+            if group_id == 637612718:
+                send_group_message_word(group_id, "本群该功能已被禁用!")
+            else:
+                change2setu(raw_message, group_id, user_id, 2)
         elif str(raw_message) == "看不懂中文":
             print("开始日语语音合成")
             ja_text = get_ja_trans(group_id)

+ 2 - 2
p2p_ll.json

@@ -40,7 +40,7 @@
   },
   "6": {
     "inputs": {
-      "text": "nsfw,best quality,masterpiece,",
+      "text": "best quality,masterpiece,",
       "speak_and_recognation": true,
       "clip": [
         "13",
@@ -54,7 +54,7 @@
   },
   "7": {
     "inputs": {
-      "text": "text, watermark",
+      "text": "watermark,signature,Artist name,lowres,bad anatomy,bad hands,text,error,missing fingers,extra digit,fewer digits,cropped,worst quality,low quality,normal quality,jpeg artifacts,signature,watermark,username,blurry,artist name worst quality,low quality,swollen or deformed toes,overlapping toes,excess toenail,incorrect toe count,uneven toe count,unnatural foot proportions.,",
       "speak_and_recognation": true,
       "clip": [
         "13",