Browse Source

绘图模型添加model=2

关习习 2 weeks ago
parent
commit
0097933aca
3 changed files with 44 additions and 4 deletions
  1. 17 0
      ai_pic.py
  2. 26 3
      main.py
  3. 1 1
      t2p_ll.json

+ 17 - 0
ai_pic.py

@@ -171,6 +171,23 @@ def story_start(prompt):
     start_paint(id, data)
     start_paint(id, data)
     return get_images_from_filenames(get_websocket_data(id))
     return get_images_from_filenames(get_websocket_data(id))
 
 
+
+def story_start2(prompt):
+    """
+    下发任务开关,在这里动态处理任务相关参数
+    """
+    with open('t2p_ll.json', 'r', encoding='utf-8') as file:
+        data = json.load(file)
+    data['6']['inputs']["text"] = prompt
+    if str(prompt).startswith("nsfw"):
+        data['7']['inputs']["text"] = config_get("pro_bad_sese")
+        print("true")
+    data["3"]["inputs"]["seed"] = random.randint(1, 2 ** 32 - 1)
+    print(prompt)
+    id = generate_instance_id()
+    start_paint(id, data)
+    return get_images_from_filenames(get_websocket_data(id, "9"))
+
 def story_start_p2p(qq, model=1):
 def story_start_p2p(qq, model=1):
     """
     """
     调用p2p的任务下发开关,传入qq号,自动根据user文件夹下的用户名搜索头像来变身
     调用p2p的任务下发开关,传入qq号,自动根据user文件夹下的用户名搜索头像来变身

+ 26 - 3
main.py

@@ -5,7 +5,7 @@ import requests
 import time
 import time
 import re
 import re
 from wakeonlan import send_magic_packet
 from wakeonlan import send_magic_packet
-from ai_pic import story_start, story_start_p2p, story_start_p2p_sese
+from ai_pic import story_start, story_start_p2p, story_start_p2p_sese, story_start2
 from msg_send_save import (send_private_message_word,save_group_message,send_group_message_pic,send_group_message_word,
 from msg_send_save import (send_private_message_word,save_group_message,send_group_message_pic,send_group_message_word,
                            send_group_poke,del_group_message,send_group_vioce)
                            send_group_poke,del_group_message,send_group_vioce)
 from chat_model import AI_chat,AI_get_picprompt,AI_lora_getpic_prompt,AI_sendphoto_ornot,get_ja_trans
 from chat_model import AI_chat,AI_get_picprompt,AI_lora_getpic_prompt,AI_sendphoto_ornot,get_ja_trans
@@ -107,7 +107,7 @@ def on_command(group_id, user_id,command):
             last_request_time = current_time
             last_request_time = current_time
             send_group_message_pic(group_id, user_id, story_start(AI_lora_getpic_prompt(pic_word)))
             send_group_message_pic(group_id, user_id, story_start(AI_lora_getpic_prompt(pic_word)))
     elif str(command).startswith("/整点瑟瑟"):
     elif str(command).startswith("/整点瑟瑟"):
-        pic_word = str(command)[len("/猫猫瑟瑟"):]
+        pic_word = str(command)[len("/整点瑟瑟"):]
         current_time = time.time()
         current_time = time.time()
         # 判断距离上次请求图片的时间间隔是否小于60秒(1分钟)
         # 判断距离上次请求图片的时间间隔是否小于60秒(1分钟)
         if group_id == 637612718:
         if group_id == 637612718:
@@ -117,7 +117,30 @@ def on_command(group_id, user_id,command):
                 send_group_message_word(group_id, "图片正在生成中...")
                 send_group_message_word(group_id, "图片正在生成中...")
                 last_request_time = current_time
                 last_request_time = current_time
                 message_id = send_group_message_pic(group_id, user_id, story_start("nsfw,"+AI_lora_getpic_prompt(pic_word)))['data']['message_id']
                 message_id = send_group_message_pic(group_id, user_id, story_start("nsfw,"+AI_lora_getpic_prompt(pic_word)))['data']['message_id']
-                time.sleep(8)
+                time.sleep(12)
+                del_group_message(message_id)
+    elif str(command).startswith("/猫猫画画2"):
+        pic_word = str(command)[len("/猫猫画画2"):]
+        current_time = time.time()
+        # 判断距离上次请求图片的时间间隔是否小于60秒(1分钟)
+        if current_time - last_request_time >= 0:
+            send_group_message_word(group_id, "图片正在生成中...")
+            last_request_time = current_time
+            send_group_message_pic(group_id, user_id, story_start2(AI_lora_getpic_prompt(pic_word)))
+    elif str(command).startswith("/整点瑟瑟2"):
+        pic_word = str(command)[len("/整点瑟瑟2"):]
+        current_time = time.time()
+        # 判断距离上次请求图片的时间间隔是否小于60秒(1分钟)
+        if group_id == 637612718:
+            send_group_message_word(group_id, "本群该功能已被禁用!")
+        else:
+            if current_time - last_request_time >= 0:
+                send_group_message_word(group_id, "图片正在生成中...")
+                last_request_time = current_time
+                message_id = \
+                send_group_message_pic(group_id, user_id, story_start2("nsfw,best quality,masterpiece," + AI_lora_getpic_prompt(pic_word)))[
+                    'data']['message_id']
+                time.sleep(12)
                 del_group_message(message_id)
                 del_group_message(message_id)
     elif str(command).startswith("/语音合成"):
     elif str(command).startswith("/语音合成"):
         send_group_message_word(group_id, "语音合成开始")
         send_group_message_word(group_id, "语音合成开始")

+ 1 - 1
t2p_ll.json

@@ -65,7 +65,7 @@
   },
   },
   "7": {
   "7": {
     "inputs": {
     "inputs": {
-      "text": "text, watermark",
+      "text": "nsfw,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,
       "speak_and_recognation": true,
       "clip": [
       "clip": [
         "10",
         "10",