mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Adds initial model switching UI
This commit is contained in:
parent
d6815f61ee
commit
a5915ccd2c
@ -166,6 +166,15 @@ class InvokeAIWebServer:
|
|||||||
config = self.get_system_config()
|
config = self.get_system_config()
|
||||||
socketio.emit('systemConfig', config)
|
socketio.emit('systemConfig', config)
|
||||||
|
|
||||||
|
@socketio.on("setModel")
|
||||||
|
def handle_set_model(model_name: str):
|
||||||
|
print(f'>> Set model requested: {model_name}')
|
||||||
|
model = self.generate.set_model(model_name)
|
||||||
|
if model is None:
|
||||||
|
socketio.emit("modelChangeFailed", { "model_name": model_name })
|
||||||
|
else:
|
||||||
|
socketio.emit("modelChanged", { "model_name": model_name })
|
||||||
|
|
||||||
@socketio.on('requestLatestImages')
|
@socketio.on('requestLatestImages')
|
||||||
def handle_request_latest_images(latest_mtime):
|
def handle_request_latest_images(latest_mtime):
|
||||||
try:
|
try:
|
||||||
@ -482,12 +491,14 @@ class InvokeAIWebServer:
|
|||||||
|
|
||||||
# App Functions
|
# App Functions
|
||||||
def get_system_config(self):
|
def get_system_config(self):
|
||||||
|
model_list = self.generate.model_cache.list_models()
|
||||||
return {
|
return {
|
||||||
'model': 'stable diffusion',
|
'model': 'stable diffusion',
|
||||||
'model_id': args.model,
|
'model_id': args.model,
|
||||||
'model_hash': self.generate.model_hash,
|
'model_hash': self.generate.model_hash,
|
||||||
'app_id': APP_ID,
|
'app_id': APP_ID,
|
||||||
'app_version': APP_VERSION,
|
'app_version': APP_VERSION,
|
||||||
|
'available_models': model_list
|
||||||
}
|
}
|
||||||
|
|
||||||
def generate_images(
|
def generate_images(
|
||||||
|
527
frontend/dist/assets/index.35e26a9a.js
vendored
527
frontend/dist/assets/index.35e26a9a.js
vendored
File diff suppressed because one or more lines are too long
517
frontend/dist/assets/index.46fb89d7.js
vendored
517
frontend/dist/assets/index.46fb89d7.js
vendored
File diff suppressed because one or more lines are too long
1
frontend/dist/assets/index.549d985b.css
vendored
Normal file
1
frontend/dist/assets/index.549d985b.css
vendored
Normal file
File diff suppressed because one or more lines are too long
517
frontend/dist/assets/index.647e65c7.js
vendored
Normal file
517
frontend/dist/assets/index.647e65c7.js
vendored
Normal file
File diff suppressed because one or more lines are too long
527
frontend/dist/assets/index.ddebc79c.js
vendored
527
frontend/dist/assets/index.ddebc79c.js
vendored
File diff suppressed because one or more lines are too long
1
frontend/dist/assets/index.fccfd8c3.css
vendored
1
frontend/dist/assets/index.fccfd8c3.css
vendored
File diff suppressed because one or more lines are too long
4
frontend/dist/index.html
vendored
4
frontend/dist/index.html
vendored
@ -6,8 +6,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>InvokeAI - A Stable Diffusion Toolkit</title>
|
<title>InvokeAI - A Stable Diffusion Toolkit</title>
|
||||||
<link rel="shortcut icon" type="icon" href="./assets/favicon.0d253ced.ico" />
|
<link rel="shortcut icon" type="icon" href="./assets/favicon.0d253ced.ico" />
|
||||||
<script type="module" crossorigin src="./assets/index.46fb89d7.js"></script>
|
<script type="module" crossorigin src="./assets/index.647e65c7.js"></script>
|
||||||
<link rel="stylesheet" href="./assets/index.fccfd8c3.css">
|
<link rel="stylesheet" href="./assets/index.549d985b.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
8
frontend/src/app/invokeai.d.ts
vendored
8
frontend/src/app/invokeai.d.ts
vendored
@ -142,8 +142,16 @@ export declare type SystemConfig = {
|
|||||||
model_hash: string;
|
model_hash: string;
|
||||||
app_id: string;
|
app_id: string;
|
||||||
app_version: string;
|
app_version: string;
|
||||||
|
available_models?: ModelList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export declare type Model = {
|
||||||
|
status: 'active' | 'cached' | 'not loaded';
|
||||||
|
description: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export declare type ModelList = Record<string, Model>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These types type data received from the server via socketio.
|
* These types type data received from the server via socketio.
|
||||||
*/
|
*/
|
||||||
|
@ -30,3 +30,5 @@ export const uploadMaskImage = createAction<File>('socketio/uploadMaskImage');
|
|||||||
export const requestSystemConfig = createAction<undefined>(
|
export const requestSystemConfig = createAction<undefined>(
|
||||||
'socketio/requestSystemConfig'
|
'socketio/requestSystemConfig'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const setModel = createAction<string>('socketio/setModel');
|
||||||
|
@ -177,6 +177,9 @@ const makeSocketIOEmitters = (
|
|||||||
emitRequestSystemConfig: () => {
|
emitRequestSystemConfig: () => {
|
||||||
socketio.emit('requestSystemConfig');
|
socketio.emit('requestSystemConfig');
|
||||||
},
|
},
|
||||||
|
emitSetModel: (modelName: string) => {
|
||||||
|
socketio.emit('setModel', modelName);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ export const socketioMiddleware = () => {
|
|||||||
emitUploadInitialImage,
|
emitUploadInitialImage,
|
||||||
emitUploadMaskImage,
|
emitUploadMaskImage,
|
||||||
emitRequestSystemConfig,
|
emitRequestSystemConfig,
|
||||||
|
emitSetModel,
|
||||||
} = makeSocketIOEmitters(store, socketio);
|
} = makeSocketIOEmitters(store, socketio);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,6 +170,11 @@ export const socketioMiddleware = () => {
|
|||||||
emitRequestSystemConfig();
|
emitRequestSystemConfig();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'socketio/setModel': {
|
||||||
|
emitSetModel(action.payload);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next(action);
|
next(action);
|
||||||
|
@ -13,9 +13,11 @@ import {
|
|||||||
useDisclosure,
|
useDisclosure,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
import { isEqual } from 'lodash';
|
import _, { isEqual } from 'lodash';
|
||||||
import { cloneElement, ReactElement } from 'react';
|
import { ChangeEvent, cloneElement, ReactElement } from 'react';
|
||||||
import { RootState, useAppSelector } from '../../../app/store';
|
import { setModel } from '../../../app/socketio/actions';
|
||||||
|
import { RootState, useAppDispatch, useAppSelector } from '../../../app/store';
|
||||||
|
import IAISelect from '../../../common/components/IAISelect';
|
||||||
import { persistor } from '../../../main';
|
import { persistor } from '../../../main';
|
||||||
import {
|
import {
|
||||||
setShouldConfirmOnDelete,
|
setShouldConfirmOnDelete,
|
||||||
@ -32,11 +34,15 @@ const systemSelector = createSelector(
|
|||||||
shouldDisplayInProgress,
|
shouldDisplayInProgress,
|
||||||
shouldConfirmOnDelete,
|
shouldConfirmOnDelete,
|
||||||
shouldDisplayGuides,
|
shouldDisplayGuides,
|
||||||
|
available_models,
|
||||||
} = system;
|
} = system;
|
||||||
return {
|
return {
|
||||||
shouldDisplayInProgress,
|
shouldDisplayInProgress,
|
||||||
shouldConfirmOnDelete,
|
shouldConfirmOnDelete,
|
||||||
shouldDisplayGuides,
|
shouldDisplayGuides,
|
||||||
|
models: available_models
|
||||||
|
? _.map(available_models, (model, key) => key)
|
||||||
|
: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -56,6 +62,7 @@ type SettingsModalProps = {
|
|||||||
* Secondary post-reset modal is included here.
|
* Secondary post-reset modal is included here.
|
||||||
*/
|
*/
|
||||||
const SettingsModal = ({ children }: SettingsModalProps) => {
|
const SettingsModal = ({ children }: SettingsModalProps) => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
const {
|
const {
|
||||||
isOpen: isSettingsModalOpen,
|
isOpen: isSettingsModalOpen,
|
||||||
onOpen: onSettingsModalOpen,
|
onOpen: onSettingsModalOpen,
|
||||||
@ -72,6 +79,7 @@ const SettingsModal = ({ children }: SettingsModalProps) => {
|
|||||||
shouldDisplayInProgress,
|
shouldDisplayInProgress,
|
||||||
shouldConfirmOnDelete,
|
shouldConfirmOnDelete,
|
||||||
shouldDisplayGuides,
|
shouldDisplayGuides,
|
||||||
|
models,
|
||||||
} = useAppSelector(systemSelector);
|
} = useAppSelector(systemSelector);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,6 +93,10 @@ const SettingsModal = ({ children }: SettingsModalProps) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleChangeModel = (e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
|
dispatch(setModel(e.target.value));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{cloneElement(children, {
|
{cloneElement(children, {
|
||||||
@ -97,6 +109,11 @@ const SettingsModal = ({ children }: SettingsModalProps) => {
|
|||||||
<ModalHeader className="settings-modal-header">Settings</ModalHeader>
|
<ModalHeader className="settings-modal-header">Settings</ModalHeader>
|
||||||
<ModalCloseButton />
|
<ModalCloseButton />
|
||||||
<ModalBody className="settings-modal-content">
|
<ModalBody className="settings-modal-content">
|
||||||
|
<IAISelect
|
||||||
|
label="Model"
|
||||||
|
validValues={models}
|
||||||
|
onChange={handleChangeModel}
|
||||||
|
/>
|
||||||
<div className="settings-modal-items">
|
<div className="settings-modal-items">
|
||||||
<SettingsModalItem
|
<SettingsModalItem
|
||||||
settingTitle="Display In-Progress Images (slower)"
|
settingTitle="Display In-Progress Images (slower)"
|
||||||
|
@ -35,6 +35,7 @@ export interface SystemState
|
|||||||
currentStatusHasSteps: boolean;
|
currentStatusHasSteps: boolean;
|
||||||
shouldDisplayGuides: boolean;
|
shouldDisplayGuides: boolean;
|
||||||
wasErrorSeen: boolean;
|
wasErrorSeen: boolean;
|
||||||
|
available_models?: InvokeAI.ModelList;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialSystemState = {
|
const initialSystemState = {
|
||||||
@ -140,7 +141,10 @@ export const systemSlice = createSlice({
|
|||||||
state.openAccordions = action.payload;
|
state.openAccordions = action.payload;
|
||||||
},
|
},
|
||||||
setSystemConfig: (state, action: PayloadAction<InvokeAI.SystemConfig>) => {
|
setSystemConfig: (state, action: PayloadAction<InvokeAI.SystemConfig>) => {
|
||||||
return { ...state, ...action.payload };
|
return {
|
||||||
|
...state,
|
||||||
|
...action.payload,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
setShouldDisplayGuides: (state, action: PayloadAction<boolean>) => {
|
setShouldDisplayGuides: (state, action: PayloadAction<boolean>) => {
|
||||||
state.shouldDisplayGuides = action.payload;
|
state.shouldDisplayGuides = action.payload;
|
||||||
|
Loading…
Reference in New Issue
Block a user