diff --git a/BaiHu/.idea/misc.xml b/BaiHu/.idea/misc.xml index 893bfad9..f648d5fe 100644 --- a/BaiHu/.idea/misc.xml +++ b/BaiHu/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/BaiHu/.idea/网站内容生成工具.iml b/BaiHu/.idea/网站内容生成工具.iml index d81667ac..a5232007 100644 --- a/BaiHu/.idea/网站内容生成工具.iml +++ b/BaiHu/.idea/网站内容生成工具.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/BaiHu/Temp/307b0c03-bbc0-6aac-8e32-642c7270d438.jpg b/BaiHu/Temp/307b0c03-bbc0-6aac-8e32-642c7270d438.jpg new file mode 100644 index 00000000..bd6821e2 Binary files /dev/null and b/BaiHu/Temp/307b0c03-bbc0-6aac-8e32-642c7270d438.jpg differ diff --git a/BaiHu/Temp/621b3c19-e1b5-3790-d83f-0b6d0a36cef8.jpg b/BaiHu/Temp/621b3c19-e1b5-3790-d83f-0b6d0a36cef8.jpg new file mode 100644 index 00000000..0e8be03c Binary files /dev/null and b/BaiHu/Temp/621b3c19-e1b5-3790-d83f-0b6d0a36cef8.jpg differ diff --git a/BaiHu/Temp/68cd78a6-253a-bffb-567a-ed2c1d91ae67.jpg b/BaiHu/Temp/68cd78a6-253a-bffb-567a-ed2c1d91ae67.jpg new file mode 100644 index 00000000..ad993bb6 Binary files /dev/null and b/BaiHu/Temp/68cd78a6-253a-bffb-567a-ed2c1d91ae67.jpg differ diff --git a/BaiHu/Temp/702ed7bc-3090-be9a-bfaa-b379de830f0c.jpg b/BaiHu/Temp/702ed7bc-3090-be9a-bfaa-b379de830f0c.jpg new file mode 100644 index 00000000..fc38e508 Binary files /dev/null and b/BaiHu/Temp/702ed7bc-3090-be9a-bfaa-b379de830f0c.jpg differ diff --git a/BaiHu/Temp/a124a441-80d4-f591-f497-aaa4e9a4bf5a.jpg b/BaiHu/Temp/a124a441-80d4-f591-f497-aaa4e9a4bf5a.jpg new file mode 100644 index 00000000..96b64e64 Binary files /dev/null and b/BaiHu/Temp/a124a441-80d4-f591-f497-aaa4e9a4bf5a.jpg differ diff --git a/BaiHu/Temp/b0fdc401-91c6-a762-b832-d40fafa07d04.jpg b/BaiHu/Temp/b0fdc401-91c6-a762-b832-d40fafa07d04.jpg new file mode 100644 index 00000000..3e758c50 Binary files /dev/null and b/BaiHu/Temp/b0fdc401-91c6-a762-b832-d40fafa07d04.jpg differ diff --git a/BaiHu/Util/SDUtil.py b/BaiHu/Util/SDUtil.py index ba98e2d2..ed86e8b6 100644 --- a/BaiHu/Util/SDUtil.py +++ b/BaiHu/Util/SDUtil.py @@ -212,9 +212,10 @@ def restart_server(webui_address): # 清理一下SD def release_sd(webui_address, comfyui_address): + pass # comfyui的显存先清理一下 - clear_comfyui_cache(comfyui_address) + # clear_comfyui_cache(comfyui_address) # 文生图一下,据测试在img_2_img报错,暴显存的时候,需要先清一下显存 - txt_2_img_blank(webui_address) + # txt_2_img_blank(webui_address) # 清理一下缓存 - clear_webui_cache(webui_address) + # clear_webui_cache(webui_address) diff --git a/BaiHu/Util/__pycache__/SDUtil.cpython-310.pyc b/BaiHu/Util/__pycache__/SDUtil.cpython-310.pyc index 82104909..17e7b2d9 100644 Binary files a/BaiHu/Util/__pycache__/SDUtil.cpython-310.pyc and b/BaiHu/Util/__pycache__/SDUtil.cpython-310.pyc differ diff --git a/BaiHu/doTask.py b/BaiHu/doTask.py index b4e7e533..2e127f7b 100644 --- a/BaiHu/doTask.py +++ b/BaiHu/doTask.py @@ -32,9 +32,6 @@ 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) - pose_image = json_data['pose_image'] args[0]['input_image'] = encode_image(input_image[0]) # 如果有特殊的姿态要求,那就用模板指定的姿态图 @@ -88,6 +85,7 @@ def webui_img_2_img(model_id, prompt_id, json_data, input_image, target_folder): printf("开始生成图片...") # 调用生图服务 response = submit_post(img2img_url, json_data) + #print(response.text) # 创建文件的完整路径 file_path = os.path.join(target_folder, str(uuid.uuid4()) + '.png') save_encoded_image(response.json()['images'][0], file_path) diff --git a/BaiHu/usbmmidd_v2/License.txt b/BaiHu/usbmmidd_v2/License.txt deleted file mode 100644 index 6d28773b..00000000 --- a/BaiHu/usbmmidd_v2/License.txt +++ /dev/null @@ -1,12 +0,0 @@ -Copyright 2014-2021 Amyuni Technologies Inc. -https://www.amyuni.com - -This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -By using this software, you accept to be prompted with an advertisement page which is not always under the control of the author. A fully commercial version is available for users who do not wisth to see those advertisements. - -Permission is granted to anyone to use this software for any purpose subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. - If you use this software in a product, an acknowledgment in the product documentation would be required. -2. Altered versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any distribution. diff --git a/BaiHu/usbmmidd_v2/VirtualMonitor.exe b/BaiHu/usbmmidd_v2/VirtualMonitor.exe deleted file mode 100644 index c851e026..00000000 Binary files a/BaiHu/usbmmidd_v2/VirtualMonitor.exe and /dev/null differ diff --git a/BaiHu/usbmmidd_v2/Win32/usbmmIdd.dll b/BaiHu/usbmmidd_v2/Win32/usbmmIdd.dll deleted file mode 100644 index 21f88d1b..00000000 Binary files a/BaiHu/usbmmidd_v2/Win32/usbmmIdd.dll and /dev/null differ diff --git a/BaiHu/usbmmidd_v2/deviceinstaller.exe b/BaiHu/usbmmidd_v2/deviceinstaller.exe deleted file mode 100644 index e9d50298..00000000 Binary files a/BaiHu/usbmmidd_v2/deviceinstaller.exe and /dev/null differ diff --git a/BaiHu/usbmmidd_v2/deviceinstaller64.exe b/BaiHu/usbmmidd_v2/deviceinstaller64.exe deleted file mode 100644 index 4afc23cf..00000000 Binary files a/BaiHu/usbmmidd_v2/deviceinstaller64.exe and /dev/null differ diff --git a/BaiHu/usbmmidd_v2/idd_instructions.txt b/BaiHu/usbmmidd_v2/idd_instructions.txt deleted file mode 100644 index e76cbd01..00000000 --- a/BaiHu/usbmmidd_v2/idd_instructions.txt +++ /dev/null @@ -1,50 +0,0 @@ -Procedure to add a virtual monitor to your system (Windows 10 Only!) - -- Download our virtual display driver from https://www.amyuni.com/downloads/usbmmidd_v2.zip -- Unpack the zip file to an empty folder, e.g. c:\temp\usbmmidd -- Make sure you read the License.txt file as with any other software product -- Open a command prompt window as Administrator (you cannot add a device to your system unless you "Run As Administrator") -- Run the following commands: - - cd c:\temp\usbmmid (or whatever destination folder you chose) - - deviceinstaller64 install usbmmidd.inf usbmmidd (If you are on a 32-bit system, replace "deviceinstaller64" by "deviceinstaller") - - Make sure you see the message that the drivers are signed by Amyuni Technologies Inc. This is a confirmation that the drivers went through Microsoft driver signing procedure and are virus free - -- Starting with version 2, the virtual monitor supports the following display resolutions by default: - -1024 x 768 pixels -1360 x 768 pixels -1440 x 900 pixels -1600 x 900 pixels -1600 x 1200 pixels -1920 x 1080 pixels [Default Resolution] -1920 x 1200 pixels -2560 x 1440 pixels -3840 x 2160 pixels - -After the first step above is executed, you can modify the list of supported resolutions by changing the following registry key: -HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WUDF\Services\usbmmIdd\Parameters\Monitors - -Up to 10 resolutions can be defined through this registry key. The keys should be named from "0" to "9". The (Default) registry value defines the default monitor resolution. - -Note that the list of resolutions can also be found in the usbmmidd.inf file that accompanies the printer driver. The inf file should not be modified in any way, otherwise the virtual display driver digital signature is invalidated. - -Once you are satisfied with the list of resolutions, you can activate the virtual monitor by running: -- deviceinstaller64 enableidd 1 - -With version 2, rou can run this command multiple times to add up to 4 virtual monitors to your system. - -The included batch file usbmmidd.bat runs these commands automatically and selects between the 32- or 64-bit version of deviceinstaller. -If you are not comfortable opening a command prompt and entering these commands, right-click on usbmmidd.bat and "Run As Administrator." - -That's it. You now have a high definition monitor in your Display Settings. You can change the display resolution, position the monitor, extend the desktop or do whatever you do with a real monitor. - -To deactivate the virtual monitor, run the command: -deviceinstaller64 enableidd 0 -If ou have added more than one monitor, you should run this command multiple times to remove all monitors. - -to reactivate a virtual monitor: -deviceinstaller64 enableidd 1 - -To completely remove the drivers from your system, you can either go through the Device Manager and uninstall "USB Mobile Monitor Virtual Display", or run the commands: -deviceinstaller64 stop usbmmidd -deviceinstaller64 remove usbmmid \ No newline at end of file diff --git a/BaiHu/usbmmidd_v2/usbmmIdd.inf b/BaiHu/usbmmidd_v2/usbmmIdd.inf deleted file mode 100644 index 836f1e9f..00000000 Binary files a/BaiHu/usbmmidd_v2/usbmmIdd.inf and /dev/null differ diff --git a/BaiHu/usbmmidd_v2/usbmmidd.bat b/BaiHu/usbmmidd_v2/usbmmidd.bat deleted file mode 100644 index a2be13d4..00000000 --- a/BaiHu/usbmmidd_v2/usbmmidd.bat +++ /dev/null @@ -1,16 +0,0 @@ -@cd /d "%~dp0" - -@goto %PROCESSOR_ARCHITECTURE% -@exit - -:AMD64 -@cmd /c deviceinstaller64.exe install usbmmidd.inf usbmmidd -@cmd /c deviceinstaller64.exe enableidd 1 -@goto end - -:x86 -@cmd /c deviceinstaller.exe install usbmmidd.inf usbmmidd -@cmd /c deviceinstaller.exe enableidd 1 - -:end -@pause diff --git a/BaiHu/usbmmidd_v2/usbmmidd.cat b/BaiHu/usbmmidd_v2/usbmmidd.cat deleted file mode 100644 index b4b2e57f..00000000 Binary files a/BaiHu/usbmmidd_v2/usbmmidd.cat and /dev/null differ diff --git a/BaiHu/usbmmidd_v2/x64/usbmmIdd.dll b/BaiHu/usbmmidd_v2/x64/usbmmIdd.dll deleted file mode 100644 index ce2d1c49..00000000 Binary files a/BaiHu/usbmmidd_v2/x64/usbmmIdd.dll and /dev/null differ diff --git a/QingLong/pom.xml b/QingLong/pom.xml index c2039433..dd5a3c56 100644 --- a/QingLong/pom.xml +++ b/QingLong/pom.xml @@ -82,7 +82,11 @@ 3.0.4-jdk17 - + + com.mashape.unirest + unirest-java + 1.4.9 + net.sf.json-lib diff --git a/QingLong/src/main/java/com/dsideal/QingLong/HuiYa/Controller/HuiYaController.java b/QingLong/src/main/java/com/dsideal/QingLong/HuiYa/Controller/HuiYaController.java index 9ce7ef64..87461b30 100644 --- a/QingLong/src/main/java/com/dsideal/QingLong/HuiYa/Controller/HuiYaController.java +++ b/QingLong/src/main/java/com/dsideal/QingLong/HuiYa/Controller/HuiYaController.java @@ -1,5 +1,6 @@ package com.dsideal.QingLong.HuiYa.Controller; +import com.alibaba.fastjson.JSONObject; import com.dsideal.QingLong.HuiYa.Model.HuiYaModel; import com.dsideal.QingLong.Interceptor.EmptyInterface; import com.dsideal.QingLong.Interceptor.IsNumericInterface; @@ -14,9 +15,12 @@ import com.jfinal.core.Controller; import com.jfinal.ext.interceptor.POST; import com.jfinal.kit.HttpKit; import com.jfinal.kit.Kv; +import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Record; +import com.mashape.unirest.http.exceptions.UnirestException; +import java.io.IOException; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; @@ -475,6 +479,93 @@ public class HuiYaController extends Controller { renderJson(res); } + /** + * 功能:生成朋友圈方案 + * + * @param token + * @param prompt 提示词 比如:美好的一天 + * @param limit 汉字个数限制 比如100 + * @param platform_id = 1; 1:小红书 2:微信朋友圈 + */ + @Before({POST.class}) + @EmptyInterface({"token", "prompt"}) + public void wxWenToWen(String token, String prompt, int limit, int platform_id) throws UnirestException { + //验证token + Kv res = ym.checkToken(token); + if (!res.getBoolean("success")) { + Kv kv = Kv.by("success", false); + kv.set("message", res.getStr("message")); + renderJson(kv); + return; + } + //换算出user_id + String user_id = res.getStr("user_id"); + //金豆够用不够用? + //扣除金豆数量 + int kouchu_jindou_count = 10; + int user_jd_count = ym.wxGetUserJinDou(user_id); + if (user_jd_count < kouchu_jindou_count) { + res.set("success", false); + res.set("message", "金豆数量不足!"); + renderJson(res); + return; + } + String result = ym.wxWenToWen(prompt, limit, platform_id); + String content = JSONObject.parseObject(result).getJSONArray("choices").getJSONObject(0).getJSONObject("message").get("content").toString(); + // 记录金豆消费日志 + Record rUser = Db.findById("t_hy_user", "user_id", user_id); + int before_jd_count = rUser.getInt("jd_count"); + int after_jd_count = before_jd_count - kouchu_jindou_count; + ym.wxAddJournal(user_id, 2, 0, 0, kouchu_jindou_count, before_jd_count, after_jd_count, "生方案消耗掉" + kouchu_jindou_count + "个金豆。"); + + Kv kv = Kv.by("success", true); + kv.set("message", content); + renderJson(kv); + } + + /** + * 功能:文生视频 + * + * @param token + * @param prompt 提示词 比如:美好的一天 + */ + @Before({POST.class}) + @EmptyInterface({"token", "prompt"}) + public void wxWenToVideo(String token, String prompt) { + //验证token + Kv res = ym.checkToken(token); + if (!res.getBoolean("success")) { + Kv kv = Kv.by("success", false); + kv.set("message", res.getStr("message")); + renderJson(kv); + return; + } + res.set("success", false); + res.set("message", "金豆数量不足!"); + renderJson(res); + } + + /** + * 功能:文生音乐 + * + * @param token + * @param prompt 提示词 比如:美好的一天 + */ + @Before({POST.class}) + @EmptyInterface({"token", "prompt"}) + public void wxWenToMusic(String token, String prompt) { + //验证token + Kv res = ym.checkToken(token); + if (!res.getBoolean("success")) { + Kv kv = Kv.by("success", false); + kv.set("message", res.getStr("message")); + renderJson(kv); + return; + } + res.set("success", false); + res.set("message", "金豆数量不足!"); + renderJson(res); + } /********************下面的内容是指Python图片生成器与WEB服务器交互使用,非小程序端支撑使用***********************/ /** @@ -580,4 +671,6 @@ public class HuiYaController extends Controller { Kv kv = Kv.by("success", success).set("message", "保存成功!"); renderJson(kv); } + + } diff --git a/QingLong/src/main/java/com/dsideal/QingLong/HuiYa/Model/HuiYaModel.java b/QingLong/src/main/java/com/dsideal/QingLong/HuiYa/Model/HuiYaModel.java index a46820b6..01cc8f22 100644 --- a/QingLong/src/main/java/com/dsideal/QingLong/HuiYa/Model/HuiYaModel.java +++ b/QingLong/src/main/java/com/dsideal/QingLong/HuiYa/Model/HuiYaModel.java @@ -14,11 +14,19 @@ import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Record; import com.jfinal.plugin.activerecord.SqlPara; +import com.mashape.unirest.http.HttpResponse; +import com.mashape.unirest.http.Unirest; +import com.mashape.unirest.http.exceptions.UnirestException; +import okhttp3.*; +import java.io.IOException; import java.util.*; public class HuiYaModel { + static { + PropKit.use("application.properties"); + } /* * 调用微信接口获取openid @@ -637,4 +645,32 @@ public class HuiYaModel { } return list; } + + + //# 第三方API接入 + public static String token = "sk-amQHwiEzPIZIB2KuF5A10dC23a0e4b02B48a7a2b6aFa0662"; + + /** + * 功能:生成朋友圈方案 + * + * @param prompt + */ + public String wxWenToWen(String prompt, int limit, int platform_id) throws UnirestException { + //平台 + String platform = ""; + if (platform_id == 1) platform = "小红书风格";//小红书风格 + if (platform_id == 2) platform = "微信朋友圈风格";//微信朋友圈 + + prompt = "帮我写一个" + platform + "方案,需要直接能够复制粘贴发表的方案,并且文字数量在" + limit + "个汉字左右:" + prompt; + + Unirest.setTimeouts(0, 0); + HttpResponse response = Unirest.post("https://goapi.gptnb.me/v1/chat/completions") + .header("Accept", "application/json") + .header("Authorization", "Bearer " + token) + .header("User-Agent", "Apifox/1.0.0 (https://apifox.com)") + .header("Content-Type", "application/json") + .body("{\n \"model\": \"gpt-4o-mini\",\n \"messages\": [{\"role\": \"user\", \"content\": \"" + prompt + "\"}]\n}") + .asString(); + return response.getBody(); + } } diff --git a/QingLong/src/main/resources/application.properties b/QingLong/src/main/resources/application.properties index 12132961..6d6b1b2f 100644 --- a/QingLong/src/main/resources/application.properties +++ b/QingLong/src/main/resources/application.properties @@ -41,4 +41,4 @@ MchID=1678768184 AdminID=16380C30-B1EA-4BFF-B5E6-4F3928CE36F3 source_img_url=http://hzkc.oss-cn-beijing.aliyuncs.com/Images/Upload/20521cb7-680c-e80e-2655-939e53393175.png # 初次使用时,赠送多少个金豆 -INIT_JD_COUNT=10 \ No newline at end of file +INIT_JD_COUNT=10 diff --git a/文档/SD配置1.png b/文档/SD配置1.png new file mode 100644 index 00000000..71a738f8 Binary files /dev/null and b/文档/SD配置1.png differ diff --git a/文档/SD配置2.png b/文档/SD配置2.png new file mode 100644 index 00000000..c8df2a5d Binary files /dev/null and b/文档/SD配置2.png differ