From a7dd7b4298d181f6abe8bf12663f960b2a002bb9 Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Tue, 7 Feb 2023 18:25:12 +1300 Subject: [PATCH 1/4] Add activeModelSelector Active Model details are used in multiple places. So makes sense to have a selector for it. --- .../features/system/store/systemSelectors.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/invokeai/frontend/src/features/system/store/systemSelectors.ts b/invokeai/frontend/src/features/system/store/systemSelectors.ts index 9c1322cf92..2c8cd68d40 100644 --- a/invokeai/frontend/src/features/system/store/systemSelectors.ts +++ b/invokeai/frontend/src/features/system/store/systemSelectors.ts @@ -1,6 +1,31 @@ +import { createSelector } from '@reduxjs/toolkit'; import { RootState } from 'app/store'; import { SystemState } from './systemSlice'; +import _ from 'lodash'; export const systemSelector = (state: RootState): SystemState => state.system; export const toastQueueSelector = (state: RootState) => state.system.toastQueue; + +export const activeModelSelector = createSelector( + systemSelector, + (system) => { + const { model_list } = system; + const activeModel = _.reduce( + model_list, + (acc, model, key) => { + if (model.status === 'active') { + acc = key; + } + return acc; + }, + '' + ); + return { ...model_list[activeModel], name: activeModel }; + }, + { + memoizeOptions: { + resultEqualityCheck: _.isEqual, + }, + } +); From f121dfe1200439af187774fa4aa053dca09b3992 Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Tue, 7 Feb 2023 18:25:45 +1300 Subject: [PATCH 2/4] Update model select to use new active model selector Hopefully this also fixes the white screen error that some users face. --- .../system/components/ModelSelect.tsx | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/invokeai/frontend/src/features/system/components/ModelSelect.tsx b/invokeai/frontend/src/features/system/components/ModelSelect.tsx index 49b7fe93fd..2cecac8506 100644 --- a/invokeai/frontend/src/features/system/components/ModelSelect.tsx +++ b/invokeai/frontend/src/features/system/components/ModelSelect.tsx @@ -5,27 +5,14 @@ import { useAppDispatch, useAppSelector } from 'app/storeHooks'; import IAISelect from 'common/components/IAISelect'; import _ from 'lodash'; import { ChangeEvent } from 'react'; -import { systemSelector } from '../store/systemSelectors'; +import { activeModelSelector, systemSelector } from '../store/systemSelectors'; const selector = createSelector( [systemSelector], (system) => { const { isProcessing, model_list } = system; const models = _.map(model_list, (model, key) => key); - const activeModel = _.reduce( - model_list, - (acc, model, key) => { - if (model.status === 'active') { - acc = key; - } - - return acc; - }, - '' - ); - const activeDesc = model_list[activeModel].description; - - return { models, activeModel, isProcessing, activeDesc }; + return { models, isProcessing }; }, { memoizeOptions: { @@ -36,8 +23,8 @@ const selector = createSelector( const ModelSelect = () => { const dispatch = useAppDispatch(); - const { models, activeModel, isProcessing, activeDesc } = - useAppSelector(selector); + const { models, isProcessing } = useAppSelector(selector); + const activeModel = useAppSelector(activeModelSelector); const handleChangeModel = (e: ChangeEvent) => { dispatch(requestModelChange(e.target.value)); }; @@ -50,9 +37,9 @@ const ModelSelect = () => { > From fcffcf560204e34d8bcb4b7ecf4da3eb3a48147a Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Tue, 7 Feb 2023 18:26:06 +1300 Subject: [PATCH 3/4] Diffusers Samplers DIsplay sampler list based on the active model. --- invokeai/frontend/src/app/constants.ts | 14 ++++++++++++++ .../options/components/MainOptions/MainSampler.tsx | 9 +++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/invokeai/frontend/src/app/constants.ts b/invokeai/frontend/src/app/constants.ts index c5221553b3..e95145eea0 100644 --- a/invokeai/frontend/src/app/constants.ts +++ b/invokeai/frontend/src/app/constants.ts @@ -16,6 +16,20 @@ export const SAMPLERS: Array = [ 'k_heun', ]; +// Valid Diffusers Samplers +export const DIFFUSERS_SAMPLERS: Array = [ + 'ddim', + 'plms', + 'k_lms', + 'dpmpp_2', + 'k_dpm_2', + 'k_dpm_2_a', + 'k_dpmpp_2', + 'k_euler', + 'k_euler_a', + 'k_heun', +]; + // Valid image widths export const WIDTHS: Array = [ 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, diff --git a/invokeai/frontend/src/features/options/components/MainOptions/MainSampler.tsx b/invokeai/frontend/src/features/options/components/MainOptions/MainSampler.tsx index 7b769a4067..abd4f027e1 100644 --- a/invokeai/frontend/src/features/options/components/MainOptions/MainSampler.tsx +++ b/invokeai/frontend/src/features/options/components/MainOptions/MainSampler.tsx @@ -1,13 +1,16 @@ import React, { ChangeEvent } from 'react'; -import { SAMPLERS } from 'app/constants'; +import { DIFFUSERS_SAMPLERS, SAMPLERS } from 'app/constants'; import { RootState } from 'app/store'; import { useAppDispatch, useAppSelector } from 'app/storeHooks'; import IAISelect from 'common/components/IAISelect'; import { setSampler } from 'features/options/store/optionsSlice'; import { useTranslation } from 'react-i18next'; +import _ from 'lodash'; +import { activeModelSelector } from 'features/system/store/systemSelectors'; export default function MainSampler() { const sampler = useAppSelector((state: RootState) => state.options.sampler); + const activeModel = useAppSelector(activeModelSelector); const dispatch = useAppDispatch(); const { t } = useTranslation(); @@ -19,7 +22,9 @@ export default function MainSampler() { label={t('options:sampler')} value={sampler} onChange={handleChangeSampler} - validValues={SAMPLERS} + validValues={ + activeModel.format === 'diffusers' ? DIFFUSERS_SAMPLERS : SAMPLERS + } styleClass="main-option-block" /> ); From 944f9e98a7fe7326ad3fb8344374e5633e0d4cf1 Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Tue, 7 Feb 2023 18:29:14 +1300 Subject: [PATCH 4/4] build (diffusers-samplers) --- ...y-7649c4ae.js => index-legacy-4add591a.js} | 8 +- .../{index.b7daf15c.js => index.f3fa9388.js} | 84 +++++++++---------- invokeai/frontend/dist/index.html | 4 +- 3 files changed, 48 insertions(+), 48 deletions(-) rename invokeai/frontend/dist/assets/{index-legacy-7649c4ae.js => index-legacy-4add591a.js} (62%) rename invokeai/frontend/dist/assets/{index.b7daf15c.js => index.f3fa9388.js} (63%) diff --git a/invokeai/frontend/dist/assets/index-legacy-7649c4ae.js b/invokeai/frontend/dist/assets/index-legacy-4add591a.js similarity index 62% rename from invokeai/frontend/dist/assets/index-legacy-7649c4ae.js rename to invokeai/frontend/dist/assets/index-legacy-4add591a.js index 66ea3a7bb9..2f1b78a2a0 100644 --- a/invokeai/frontend/dist/assets/index-legacy-7649c4ae.js +++ b/invokeai/frontend/dist/assets/index-legacy-4add591a.js @@ -18,7 +18,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -var Y=a.exports,Z=G.exports;function X(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n