add tooltips & status messages to model conversion

This commit is contained in:
psychedelicious 2023-02-15 22:28:36 +11:00
parent 6ae7560f66
commit bcb1fbe031
9 changed files with 74 additions and 11 deletions

View File

@ -448,7 +448,7 @@ class InvokeAIWebServer:
new_model_list = self.generate.model_manager.list_models() new_model_list = self.generate.model_manager.list_models()
socketio.emit( socketio.emit(
"newModelAdded", "modelConverted",
{"new_model_name": model_name, {"new_model_name": model_name,
"model_list": new_model_list, 'update': True}, "model_list": new_model_list, 'update': True},
) )

View File

@ -58,5 +58,7 @@
"statusUpscaling": "Upscaling", "statusUpscaling": "Upscaling",
"statusUpscalingESRGAN": "Upscaling (ESRGAN)", "statusUpscalingESRGAN": "Upscaling (ESRGAN)",
"statusLoadingModel": "Loading Model", "statusLoadingModel": "Loading Model",
"statusModelChanged": "Model Changed" "statusModelChanged": "Model Changed",
"statusConvertingModel": "Converting Model",
"statusModelConverted": "Model Converted"
} }

View File

@ -72,14 +72,16 @@
"convertToDiffusersHelpText4": "This is a one time process only. It might take around 30s-60s depending on the specifications of your computer.", "convertToDiffusersHelpText4": "This is a one time process only. It might take around 30s-60s depending on the specifications of your computer.",
"convertToDiffusersHelpText5": "Please make sure you have enough disk space. Models generally vary between 4GB-7GB in size.", "convertToDiffusersHelpText5": "Please make sure you have enough disk space. Models generally vary between 4GB-7GB in size.",
"convertToDiffusersHelpText6": "Do you wish to convert this model?", "convertToDiffusersHelpText6": "Do you wish to convert this model?",
"convertToDiffusersSaveLocation": "Save Location",
"v1": "v1", "v1": "v1",
"v2": "v2", "v2": "v2",
"inpainting": "v1 Inpainting", "inpainting": "v1 Inpainting",
"customConfig": "Custom Config", "customConfig": "Custom Config",
"pathToCustomConfig": "Path To Custom Config", "pathToCustomConfig": "Path To Custom Config",
"statusConverting": "Converting", "statusConverting": "Converting",
"sameFolder": "Same Folder", "modelConverted": "Model Converted",
"invokeRoot": "Invoke Models", "sameFolder": "Same folder",
"invokeRoot": "InvokeAI folder",
"custom": "Custom", "custom": "Custom",
"customSaveLocation": "Custom Save Location" "customSaveLocation": "Custom Save Location"
} }

View File

@ -234,6 +234,11 @@ export declare type ModelChangeResponse = {
model_list: ModelList; model_list: ModelList;
}; };
export declare type ModelConvertedResponse = {
converted_model_name: string;
model_list: ModelList;
};
export declare type ModelAddedResponse = { export declare type ModelAddedResponse = {
new_model_name: string; new_model_name: string;
model_list: ModelList; model_list: ModelList;

View File

@ -15,6 +15,7 @@ import {
addLogEntry, addLogEntry,
generationRequested, generationRequested,
modelChangeRequested, modelChangeRequested,
modelConvertRequested,
setIsProcessing, setIsProcessing,
} from 'features/system/store/systemSlice'; } from 'features/system/store/systemSlice';
import { InvokeTabName } from 'features/ui/store/tabMap'; import { InvokeTabName } from 'features/ui/store/tabMap';
@ -181,6 +182,7 @@ const makeSocketIOEmitters = (
emitConvertToDiffusers: ( emitConvertToDiffusers: (
modelToConvert: InvokeAI.InvokeModelConversionProps modelToConvert: InvokeAI.InvokeModelConversionProps
) => { ) => {
dispatch(modelConvertRequested());
socketio.emit('convertToDiffusers', modelToConvert); socketio.emit('convertToDiffusers', modelToConvert);
}, },
emitRequestModelChange: (modelName: string) => { emitRequestModelChange: (modelName: string) => {

View File

@ -365,6 +365,7 @@ const makeSocketIOListeners = (
const { new_model_name, model_list, update } = data; const { new_model_name, model_list, update } = data;
dispatch(setModelList(model_list)); dispatch(setModelList(model_list));
dispatch(setIsProcessing(false)); dispatch(setIsProcessing(false));
dispatch(setCurrentStatus(i18n.t('modelmanager:modelAdded')));
dispatch( dispatch(
addLogEntry({ addLogEntry({
timestamp: dateFormat(new Date(), 'isoDateTime'), timestamp: dateFormat(new Date(), 'isoDateTime'),
@ -407,6 +408,30 @@ const makeSocketIOListeners = (
}) })
); );
}, },
onModelConverted: (data: InvokeAI.ModelConvertedResponse) => {
const { converted_model_name, model_list } = data;
dispatch(setModelList(model_list));
dispatch(setCurrentStatus(i18n.t('common:statusModelConverted')));
dispatch(setIsProcessing(false));
dispatch(setIsCancelable(true));
dispatch(
addLogEntry({
timestamp: dateFormat(new Date(), 'isoDateTime'),
message: `Model converted: ${converted_model_name}`,
level: 'info',
})
);
dispatch(
addToast({
title: `${i18n.t(
'modelmanager:modelConverted'
)}: ${converted_model_name}`,
status: 'success',
duration: 2500,
isClosable: true,
})
);
},
onModelChanged: (data: InvokeAI.ModelChangeResponse) => { onModelChanged: (data: InvokeAI.ModelChangeResponse) => {
const { model_name, model_list } = data; const { model_name, model_list } = data;
dispatch(setModelList(model_list)); dispatch(setModelList(model_list));

View File

@ -48,6 +48,7 @@ export const socketioMiddleware = () => {
onFoundModels, onFoundModels,
onNewModelAdded, onNewModelAdded,
onModelDeleted, onModelDeleted,
onModelConverted,
onModelChangeFailed, onModelChangeFailed,
onTempFolderEmptied, onTempFolderEmptied,
} = makeSocketIOListeners(store); } = makeSocketIOListeners(store);
@ -126,6 +127,10 @@ export const socketioMiddleware = () => {
onModelDeleted(data); onModelDeleted(data);
}); });
socketio.on('modelConverted', (data: InvokeAI.ModelConvertedResponse) => {
onModelConverted(data);
});
socketio.on('modelChanged', (data: InvokeAI.ModelChangeResponse) => { socketio.on('modelChanged', (data: InvokeAI.ModelChangeResponse) => {
onModelChanged(data); onModelChanged(data);
}); });

View File

@ -5,6 +5,7 @@ import {
RadioGroup, RadioGroup,
Text, Text,
UnorderedList, UnorderedList,
Tooltip,
} from '@chakra-ui/react'; } from '@chakra-ui/react';
import { convertToDiffusers } from 'app/socketio/actions'; import { convertToDiffusers } from 'app/socketio/actions';
import { RootState } from 'app/store'; import { RootState } from 'app/store';
@ -12,7 +13,6 @@ import { useAppDispatch, useAppSelector } from 'app/storeHooks';
import IAIAlertDialog from 'common/components/IAIAlertDialog'; import IAIAlertDialog from 'common/components/IAIAlertDialog';
import IAIButton from 'common/components/IAIButton'; import IAIButton from 'common/components/IAIButton';
import IAIInput from 'common/components/IAIInput'; import IAIInput from 'common/components/IAIInput';
import { setIsProcessing } from 'features/system/store/systemSlice';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -60,7 +60,6 @@ export default function ModelConvert(props: ModelConvertProps) {
? customSaveLocation ? customSaveLocation
: null, : null,
}; };
dispatch(setIsProcessing(true));
dispatch(convertToDiffusers(modelToConvert)); dispatch(convertToDiffusers(modelToConvert));
}; };
@ -98,12 +97,28 @@ export default function ModelConvert(props: ModelConvertProps) {
<Flex flexDir="column" gap={4}> <Flex flexDir="column" gap={4}>
<Flex marginTop="1rem" flexDir="column" gap={2}> <Flex marginTop="1rem" flexDir="column" gap={2}>
<Text fontWeight="bold">Save Location</Text> <Text fontWeight="bold">
{t('modelmanager:convertToDiffusersSaveLocation')}
</Text>
<RadioGroup value={saveLocation} onChange={(v) => setSaveLocation(v)}> <RadioGroup value={saveLocation} onChange={(v) => setSaveLocation(v)}>
<Flex gap={4}> <Flex gap={4}>
<Radio value="same">{t('modelmanager:sameFolder')}</Radio> <Radio value="same">
<Radio value="root">{t('modelmanager:invokeRoot')}</Radio> <Tooltip label="Save converted model in the same folder">
<Radio value="custom">{t('modelmanager:custom')}</Radio> {t('modelmanager:sameFolder')}
</Tooltip>
</Radio>
<Radio value="root">
<Tooltip label="Save converted model in the InvokeAI root folder">
{t('modelmanager:invokeRoot')}
</Tooltip>
</Radio>
<Radio value="custom">
<Tooltip label="Save converted model in a custom folder">
{t('modelmanager:custom')}
</Tooltip>
</Radio>
</Flex> </Flex>
</RadioGroup> </RadioGroup>
</Flex> </Flex>

View File

@ -214,6 +214,12 @@ export const systemSlice = createSlice({
state.isProcessing = true; state.isProcessing = true;
state.currentStatusHasSteps = false; state.currentStatusHasSteps = false;
}, },
modelConvertRequested: (state) => {
state.currentStatus = i18n.t('common:statusConvertingModel');
state.isCancelable = false;
state.isProcessing = true;
state.currentStatusHasSteps = false;
},
setSaveIntermediatesInterval: (state, action: PayloadAction<number>) => { setSaveIntermediatesInterval: (state, action: PayloadAction<number>) => {
state.saveIntermediatesInterval = action.payload; state.saveIntermediatesInterval = action.payload;
}, },
@ -265,6 +271,7 @@ export const {
setModelList, setModelList,
setIsCancelable, setIsCancelable,
modelChangeRequested, modelChangeRequested,
modelConvertRequested,
setSaveIntermediatesInterval, setSaveIntermediatesInterval,
setEnableImageDebugging, setEnableImageDebugging,
generationRequested, generationRequested,