mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): initial implementation of model loading
- Update model listing code to use `rtk-query` - Update all graph generation to use new `pipeline_model_loader` node
This commit is contained in:
@ -1,12 +1,9 @@
|
||||
import type { PayloadAction } from '@reduxjs/toolkit';
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import { DEFAULT_SCHEDULER_NAME, Scheduler } from 'app/constants';
|
||||
import { ModelLoaderTypes } from 'features/system/components/ModelSelect';
|
||||
import { DEFAULT_SCHEDULER_NAME } from 'app/constants';
|
||||
import { configChanged } from 'features/system/store/configSlice';
|
||||
import { clamp, sortBy } from 'lodash-es';
|
||||
import { clamp } from 'lodash-es';
|
||||
import { ImageDTO } from 'services/api';
|
||||
import { imageUrlsReceived } from 'services/thunks/image';
|
||||
import { receivedModels } from 'services/thunks/model';
|
||||
import {
|
||||
CfgScaleParam,
|
||||
HeightParam,
|
||||
@ -50,7 +47,6 @@ export interface GenerationState {
|
||||
horizontalSymmetrySteps: number;
|
||||
verticalSymmetrySteps: number;
|
||||
model: ModelParam;
|
||||
currentModelType: ModelLoaderTypes;
|
||||
shouldUseSeamless: boolean;
|
||||
seamlessXAxis: boolean;
|
||||
seamlessYAxis: boolean;
|
||||
@ -85,7 +81,6 @@ export const initialGenerationState: GenerationState = {
|
||||
horizontalSymmetrySteps: 0,
|
||||
verticalSymmetrySteps: 0,
|
||||
model: '',
|
||||
currentModelType: 'sd1_model_loader',
|
||||
shouldUseSeamless: false,
|
||||
seamlessXAxis: true,
|
||||
seamlessYAxis: true,
|
||||
@ -221,33 +216,14 @@ export const generationSlice = createSlice({
|
||||
modelSelected: (state, action: PayloadAction<string>) => {
|
||||
state.model = action.payload;
|
||||
},
|
||||
setCurrentModelType: (state, action: PayloadAction<ModelLoaderTypes>) => {
|
||||
state.currentModelType = action.payload;
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
builder.addCase(receivedModels.fulfilled, (state, action) => {
|
||||
if (!state.model) {
|
||||
const firstModel = sortBy(action.payload, 'name')[0];
|
||||
state.model = firstModel.name;
|
||||
}
|
||||
});
|
||||
|
||||
builder.addCase(configChanged, (state, action) => {
|
||||
const defaultModel = action.payload.sd?.defaultModel;
|
||||
if (defaultModel && !state.model) {
|
||||
state.model = defaultModel;
|
||||
}
|
||||
});
|
||||
|
||||
// builder.addCase(imageUrlsReceived.fulfilled, (state, action) => {
|
||||
// const { image_name, image_url, thumbnail_url } = action.payload;
|
||||
|
||||
// if (state.initialImage?.image_name === image_name) {
|
||||
// state.initialImage.image_url = image_url;
|
||||
// state.initialImage.thumbnail_url = thumbnail_url;
|
||||
// }
|
||||
// });
|
||||
},
|
||||
});
|
||||
|
||||
@ -284,7 +260,6 @@ export const {
|
||||
setVerticalSymmetrySteps,
|
||||
initialImageChanged,
|
||||
modelSelected,
|
||||
setCurrentModelType,
|
||||
setShouldUseNoiseSettings,
|
||||
setSeamless,
|
||||
setSeamlessXAxis,
|
||||
|
@ -154,3 +154,17 @@ export type StrengthParam = z.infer<typeof zStrength>;
|
||||
*/
|
||||
export const isValidStrength = (val: unknown): val is StrengthParam =>
|
||||
zStrength.safeParse(val).success;
|
||||
|
||||
// /**
|
||||
// * Zod schema for BaseModelType
|
||||
// */
|
||||
// export const zBaseModelType = z.enum(['sd-1', 'sd-2']);
|
||||
// /**
|
||||
// * Type alias for base model type, inferred from its zod schema. Should be identical to the type alias from OpenAPI.
|
||||
// */
|
||||
// export type BaseModelType = z.infer<typeof zBaseModelType>;
|
||||
// /**
|
||||
// * Validates/type-guards a value as a base model type
|
||||
// */
|
||||
// export const isValidBaseModelType = (val: unknown): val is BaseModelType =>
|
||||
// zBaseModelType.safeParse(val).success;
|
||||
|
Reference in New Issue
Block a user