diff --git a/.gitignore b/.gitignore index c8f44e2..d3ec3dd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ resources/scripts/lama/dist resources/scripts/lama/build resources/scripts/lama/lama_inpaint.exe resources/scripts/virtual py +resources/scripts/_internal resources/logger resources/scripts/Temp resources/image/Temp* diff --git a/package-lock.json b/package-lock.json index 83f9875..77c9a99 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "laitool", - "version": "2.2.7", + "version": "2.2.8", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index a95cbe8..9dc9a74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "laitool", - "version": "2.2.7", + "version": "2.2.8", "description": "An Electron application with Vue", "main": "./out/main/index.js", "author": "example.com", @@ -77,11 +77,14 @@ "!resources/" ], "extraResources": [ - "resources/package/**", + "resources/package/exittool/**", + "resources/package/ffmpeg-2023-12-07-git-f89cff96d0-full_build/**", + "resources/package/Improve/**", "resources/image/style/**", "resources/image/zhanwei.png", "resources/scripts/model/**", "resources/scripts/Lai.exe", + "resources/scripts/_internal/**", "resources/scripts/lama/lama_inpaint.exe", "resources/scripts/lama/model/**", "resources/scripts/discordScript.js", @@ -92,4 +95,4 @@ "icon": "./resources/icon.ico" } } -} +} \ No newline at end of file diff --git a/resources/image/c_s/36c7fea1-5747-41c8-a624-14a29a504585.png b/resources/image/c_s/36c7fea1-5747-41c8-a624-14a29a504585.png new file mode 100644 index 0000000..3aec420 Binary files /dev/null and b/resources/image/c_s/36c7fea1-5747-41c8-a624-14a29a504585.png differ diff --git a/resources/scripts/Lai.spec b/resources/scripts/Lai.spec index 6a9e0f2..b8e6262 100644 --- a/resources/scripts/Lai.spec +++ b/resources/scripts/Lai.spec @@ -3,10 +3,10 @@ from PyInstaller.building.datastruct import Tree from PyInstaller.utils.hooks import get_package_paths - PACKAGE_DIRECTORY = get_package_paths('faster_whisper')[1] datas = [(PACKAGE_DIRECTORY, 'faster_whisper')] + a = Analysis( ['Lai.py'], pathex=[], @@ -24,16 +24,13 @@ pyz = PYZ(a.pure) exe = EXE( pyz, a.scripts, - a.binaries, - a.datas, [], + exclude_binaries=True, name='Lai', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, - upx_exclude=[], - runtime_tmpdir=None, console=True, disable_windowed_traceback=False, argv_emulation=False, @@ -41,3 +38,12 @@ exe = EXE( codesign_identity=None, entitlements_file=None, ) +coll = COLLECT( + exe, + a.binaries, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='Lai', +) diff --git a/resources/scripts/Lai_1.spec b/resources/scripts/Lai_1.spec new file mode 100644 index 0000000..6a9e0f2 --- /dev/null +++ b/resources/scripts/Lai_1.spec @@ -0,0 +1,43 @@ +# -*- mode: python ; coding: utf-8 -*- + +from PyInstaller.building.datastruct import Tree +from PyInstaller.utils.hooks import get_package_paths + + +PACKAGE_DIRECTORY = get_package_paths('faster_whisper')[1] +datas = [(PACKAGE_DIRECTORY, 'faster_whisper')] + +a = Analysis( + ['Lai.py'], + pathex=[], + binaries=[], + datas=datas, + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='Lai', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) diff --git a/resources/scripts/clip.py b/resources/scripts/clip.py index d4b53ca..249861c 100644 --- a/resources/scripts/clip.py +++ b/resources/scripts/clip.py @@ -245,10 +245,8 @@ class Clip: command.append("-c:v") command.append("h264_cuvid") # 使用 NVIDIA CUVID 解码器进行解码 elif self.gpu_type == "AMD": - command.append("-hwaccel") - command.append("vaapi") command.append("-c:v") - command.append("h264_vaapi") + command.append("h264") command.append("-i") command.append(random_path) command.append("-ss") @@ -266,7 +264,7 @@ class Clip: if self.gpu_type == "NVIDIA": command.append("h264_nvenc") elif self.gpu_type == "AMD": - command.append("h264_vaapi") + command.append("h264_amf") else: command.append("libx264") command.append("-preset") @@ -485,7 +483,7 @@ class Clip: if self.gpu_type == "NVIDIA": command.append("h264_nvenc") elif self.gpu_type == "AMD": - command.append("h264_vaapi") + command.append("h264_amf") else: command.append("libx264") diff --git a/resources/scripts/iamge_to_video.py b/resources/scripts/iamge_to_video.py index 80bb936..520148a 100644 --- a/resources/scripts/iamge_to_video.py +++ b/resources/scripts/iamge_to_video.py @@ -473,7 +473,7 @@ class ImageToVideo: if self.gpu_type == "NVIDIA": cmd.append("h264_nvenc") elif self.gpu_type == "AMD": - cmd.append("h264_vaapi") + cmd.append("h264_amf") else: cmd.append("libx264") diff --git a/resources/scripts/shotSplit.py b/resources/scripts/shotSplit.py index b647a06..5256d35 100644 --- a/resources/scripts/shotSplit.py +++ b/resources/scripts/shotSplit.py @@ -100,7 +100,7 @@ def ClipVideo(video_path, out_folder, image_out_folder, sensitivity, gpu_type): if gpu_type == "NVIDIA": command.append("h264_nvenc") elif gpu_type == "AMD": - command.append("h264_vaapi") + command.append("h264_amf") else: command.append("libx264") diff --git a/src/api/apiBasic.js b/src/api/apiBasic.js index 816359e..e3fc285 100644 --- a/src/api/apiBasic.js +++ b/src/api/apiBasic.js @@ -1,6 +1,10 @@ const { net } = require('electron'); +function isString(contentType) { + return contentType.startsWith('text/plain') || contentType.startsWith('application/json'); +} + let basicApi = { /** * 使用electron的net模块实现的get方法 @@ -12,9 +16,27 @@ let basicApi = { return new Promise((resolve, reject) => { const request = net.request({ url, method: 'GET', headers }); request.on('response', (response) => { - let data = ''; + let data; + if (isString(response.headers["content-type"])) { + data = ''; + } else if (response.headers["content-type"].startsWith("image/")) { + // 处理图片数据 + data = [] + } + else { + throw new Error("未知的请求返回数据类型"); + } + response.on('data', (chunk) => { - data += chunk; + if (isString(response.headers["content-type"])) { + // 处理 JSON 数据 + data += chunk; + } else if (response.headers['content-type'].startsWith('image/')) { + // 处理图片数据 + data.push(chunk); + } else { + throw new Error("未知的请求返回数据类型"); + } }); response.on('end', () => { // 结束的时候检查请求的状态码,是不是成功的请求,不是返回错误,有些其他的状态码也是成功的请求,并且返回错误提示 @@ -24,10 +46,13 @@ let basicApi = { } let parsedData; - if (response.headers['content-type'].includes('application/json')) { + if (isString(response.headers["content-type"])) { parsedData = JSON.parse(data); + } else if (response.headers['content-type'].startsWith('image/')) { + // parsedData = responseData; + parsedData = Buffer.concat(data); } else { - parsedData = data; + throw new Error("未知的请求返回数据类型"); } resolve({ @@ -71,8 +96,7 @@ let basicApi = { request.on('response', (response) => { let responseData; - if (response.headers["content-type"] === "application/json") { - + if (isString(response.headers["content-type"])) { responseData = ''; } else if (response.headers["content-type"].startsWith("image/")) { // 处理图片数据 @@ -83,12 +107,14 @@ let basicApi = { } response.on('data', (chunk) => { - if (response.headers['content-type'] === 'application/json') { + if (isString(response.headers["content-type"])) { // 处理 JSON 数据 responseData += chunk; } else if (response.headers['content-type'].startsWith('image/')) { // 处理图片数据 responseData.push(chunk); + } else { + throw new Error("未知的请求返回数据类型"); } }); @@ -99,7 +125,7 @@ let basicApi = { } let parsedData; - if (response.headers['content-type'].includes('application/json')) { + if (isString(response.headers["content-type"])) { parsedData = JSON.parse(responseData); } else if (response.headers['content-type'].startsWith('image/')) { // parsedData = responseData; diff --git a/src/api/discordApi.js b/src/api/discordApi.js index 891b86a..467517c 100644 --- a/src/api/discordApi.js +++ b/src/api/discordApi.js @@ -88,7 +88,13 @@ export class DiscordAPI { res_data = JSON.parse(res_data); } if (res_data && res_data.code != 1) { - throw new Error(res_data.message); + if (res_data.message) { + throw new Error(res_data.message); + } else if (res_data.description) { + throw new Error(res_data.description) + } else { + throw new Error("未知错误,可联系管理员排查"); + } } return res_data; } catch (error) { diff --git a/src/main/Original/MJOriginalImageGenerate.js b/src/main/Original/MJOriginalImageGenerate.js index 52a0115..bbeb19e 100644 --- a/src/main/Original/MJOriginalImageGenerate.js +++ b/src/main/Original/MJOriginalImageGenerate.js @@ -277,14 +277,14 @@ export class MJOriginalImageGenerate { let imagine_url = apiUrl.mj_url.imagine; let once_get_task = apiUrl.mj_url.once_get_task; let task_count = mjSetting.task_count ? mjSetting.task_count : 3; - let request_model = mjSetting.request_model ? mjSetting.request_model : "relaxed"; + let mj_speed = mjSetting.mj_speed ? mjSetting.mj_speed : "relaxed"; let res; // 判断当前的API是哪个 if (imagine_url.includes("mjapi.deepwl.net")) { // DrawAPI(MJ) let data = { prompt: prompt, - mode: request_model == "fast" ? "FAST" : "RELAX", + mode: mj_speed == "fast" ? "FAST" : "RELAX", } let headers = { "Authorization": mjSetting.api_key @@ -300,7 +300,7 @@ export class MJOriginalImageGenerate { botType: "MID_JOURNEY", accountFilter: { modes: [ - request_model == "fast" ? "FAST" : "RELAX" + mj_speed == "fast" ? "FAST" : "RELAX" ] } } diff --git a/src/main/Public/SD.js b/src/main/Public/SD.js index ed6414f..36b8399 100644 --- a/src/main/Public/SD.js +++ b/src/main/Public/SD.js @@ -110,7 +110,7 @@ export class SD { return successMessage(data); } catch (error) { - return errorMessage(error.toString()); + return errorMessage("加载数据失败,错误信息如下:" +error.toString()); } }