From d36660a063aaade8048bb9e6be0a2a4df5c5f16a Mon Sep 17 00:00:00 2001 From: AEtheve <30652308+AEtheve@users.noreply.github.com> Date: Sun, 8 Jan 2023 17:08:46 +0100 Subject: [PATCH 1/7] Implementation of CoreML + Live Render Preview With this implementation, we can select a CoreML model for the Text To Image mode, which increases performance (currently, the model must be manually added to the .diffusonbee/coreml_models folder and the compiled executable in the src/Debug folder). --- electron_app/src/App.vue | 38 +++++- electron_app/src/StableDiffusion.vue | 40 ++++-- electron_app/src/bridge.js | 73 +++++++++-- electron_app/src/components/Img2Img.vue | 29 ++++- electron_app/src/components/ImgGenerate.vue | 116 +++++++++++++----- electron_app/src/components/Settings.vue | 13 ++ .../src/components_bare/ApplicationFrame.vue | 11 ++ .../src/components_bare/SDOptionsDropdown.vue | 17 ++- electron_app/src/native_functions.js | 29 ++++- electron_app/src/py_vue_bridge.js | 8 +- 10 files changed, 310 insertions(+), 64 deletions(-) diff --git a/electron_app/src/App.vue b/electron_app/src/App.vue index 6698e616..47ef3dac 100644 --- a/electron_app/src/App.vue +++ b/electron_app/src/App.vue @@ -14,6 +14,7 @@ import { bind_app_component } from "./py_vue_bridge.js" -import { send_to_py } from "./py_vue_bridge.js" +import { send_to_py, send_to_swift } from "./py_vue_bridge.js" import {native_confirm, native_alert } from "./native_functions_vue_bridge.js" import StableDiffusion from "./StableDiffusion.vue" import SplashScreen from './components_bare/SplashScreen.vue' @@ -146,7 +147,6 @@ export default this.stable_diffusion = this.$refs.stable_diffusion; bind_app_component(this); - send_to_py("strt"); if( require('../package.json').is_dev || require('../package.json').build_number.includes("dev") ) alert("Not checking for updates.") @@ -176,10 +176,42 @@ export default if(!data.custom_models){ data.custom_models = {} } + if (!data.selected_model) { + data.selected_model = "" + } if( data ){ Vue.set(this.app_state , 'app_data' , data) } - + + let custom_models = window.ipcRenderer.sendSync('list_custom_models'); + + for (let i = 0; i < custom_models.length; i++) { + const model_name = custom_models[i].name; + const model_path = custom_models[i].path; + if( model_name.endsWith(".tdict") ){ + if( !data.custom_models[model_name.slice(0,-6)] ){ + Vue.set(this.app_state.app_data.custom_models , model_name.slice(0,-6) , { + name : model_name.slice(0,-6), + orig_path : model_path, + is_coreml : false}) + } + } + else{ + if( !data.custom_models[model_name] ){ + Vue.set(this.app_state.app_data.custom_models , model_name + " [CoreML ]", { + name : model_name, + orig_path : model_path, + is_coreml : true}) + } + } + } + + if (data.selected_model.endsWith(" [CoreML ]")) { + send_to_swift("strt"); + } + else { + send_to_py("strt"); + } }, diff --git a/electron_app/src/StableDiffusion.vue b/electron_app/src/StableDiffusion.vue index 3bc0b837..da6dd3cf 100644 --- a/electron_app/src/StableDiffusion.vue +++ b/electron_app/src/StableDiffusion.vue @@ -3,7 +3,7 @@