mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
v2 Conversion Support & Radio Picker
Converted the picker options to a Radio Group and also updated the backend to use the appropriate config if it is a v2 model that needs to be converted.
This commit is contained in:
parent
11e422cf29
commit
96926d6648
@ -422,14 +422,21 @@ class InvokeAIWebServer:
|
||||
original_config_file = Path(
|
||||
Globals.root, original_config_file)
|
||||
|
||||
if model_to_convert['is_inpainting']:
|
||||
if model_to_convert['model_type'] == 'inpainting':
|
||||
original_config_file = Path(
|
||||
'configs',
|
||||
'stable-diffusion',
|
||||
'v1-inpainting-inference.yaml' if model_to_convert['is_inpainting'] else 'v1-inference.yaml'
|
||||
'v1-inpainting-inference.yaml'
|
||||
)
|
||||
|
||||
if model_to_convert['custom_config'] is not None:
|
||||
if model_to_convert['model_type'] == '2':
|
||||
original_config_file = Path(
|
||||
'configs',
|
||||
'stable-diffusion',
|
||||
'v2-inference-v.yaml'
|
||||
)
|
||||
|
||||
if model_to_convert['model_type'] == 'custom' and model_to_convert['custom_config'] is not None:
|
||||
original_config_file = Path(
|
||||
model_to_convert['custom_config'])
|
||||
|
||||
|
@ -72,8 +72,10 @@
|
||||
"convertToDiffusersHelpText4": "This is a one time process only. It might take around 30s-60s depending on the specifications of your computer.",
|
||||
"convertToDiffusersHelpText5": "This process will create a Diffusers version of this model in the same directory as your checkpoint. Please make sure you have enough disk space.",
|
||||
"convertToDiffusersHelpText6": "Do you wish to convert this model?",
|
||||
"inpaintingModel": "Inpainting Model",
|
||||
"customConfig": "Custom Config",
|
||||
"v1": "v1",
|
||||
"v2": "v2",
|
||||
"inpainting": "v1 Inpainting",
|
||||
"custom": "Custom",
|
||||
"pathToCustomConfig": "Path To Custom Config",
|
||||
"statusConverting": "Converting"
|
||||
}
|
||||
|
2
invokeai/frontend/src/app/invokeai.d.ts
vendored
2
invokeai/frontend/src/app/invokeai.d.ts
vendored
@ -221,7 +221,7 @@ export declare type InvokeDiffusersModelConfigProps = {
|
||||
|
||||
export declare type InvokeModelConversionProps = {
|
||||
name: string;
|
||||
is_inpainting: boolean;
|
||||
model_type: string;
|
||||
custom_config: string | null;
|
||||
};
|
||||
|
||||
|
@ -1,10 +1,16 @@
|
||||
import { Flex, ListItem, Text, UnorderedList } from '@chakra-ui/react';
|
||||
import {
|
||||
Flex,
|
||||
ListItem,
|
||||
Radio,
|
||||
RadioGroup,
|
||||
Text,
|
||||
UnorderedList,
|
||||
} from '@chakra-ui/react';
|
||||
import { convertToDiffusers } from 'app/socketio/actions';
|
||||
import { RootState } from 'app/store';
|
||||
import { useAppDispatch, useAppSelector } from 'app/storeHooks';
|
||||
import IAIAlertDialog from 'common/components/IAIAlertDialog';
|
||||
import IAIButton from 'common/components/IAIButton';
|
||||
import IAICheckbox from 'common/components/IAICheckbox';
|
||||
import IAIInput from 'common/components/IAIInput';
|
||||
import { setIsProcessing } from 'features/system/store/systemSlice';
|
||||
import { useState, useEffect } from 'react';
|
||||
@ -23,9 +29,8 @@ export default function ModelConvert(props: ModelConvertProps) {
|
||||
|
||||
const retrievedModel = model_list[model];
|
||||
|
||||
const [isInpainting, setIsInpainting] = useState<boolean>(false);
|
||||
const [customConfig, setIsCustomConfig] = useState<boolean>(false);
|
||||
const [pathToConfig, setPathToConfig] = useState<string>('');
|
||||
const [modelType, setModelType] = useState<string>('1');
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
const { t } = useTranslation();
|
||||
@ -40,8 +45,7 @@ export default function ModelConvert(props: ModelConvertProps) {
|
||||
|
||||
// Need to manually handle local state reset because the component does not re-render.
|
||||
const stateReset = () => {
|
||||
setIsInpainting(false);
|
||||
setIsCustomConfig(false);
|
||||
setModelType('1');
|
||||
setPathToConfig('');
|
||||
};
|
||||
|
||||
@ -58,8 +62,9 @@ export default function ModelConvert(props: ModelConvertProps) {
|
||||
const modelConvertHandler = () => {
|
||||
const modelConvertData = {
|
||||
name: model,
|
||||
is_inpainting: isInpainting,
|
||||
custom_config: customConfig && pathToConfig !== '' ? pathToConfig : null,
|
||||
model_type: modelType,
|
||||
custom_config:
|
||||
modelType === 'custom' && pathToConfig !== '' ? pathToConfig : null,
|
||||
};
|
||||
|
||||
dispatch(setIsProcessing(true));
|
||||
@ -86,6 +91,7 @@ export default function ModelConvert(props: ModelConvertProps) {
|
||||
🧨 {t('modelmanager:convertToDiffusers')}
|
||||
</IAIButton>
|
||||
}
|
||||
motionPreset="slideInBottom"
|
||||
>
|
||||
<Flex flexDirection="column" rowGap={4}>
|
||||
<Text>{t('modelmanager:convertToDiffusersHelpText1')}</Text>
|
||||
@ -96,28 +102,20 @@ export default function ModelConvert(props: ModelConvertProps) {
|
||||
<ListItem>{t('modelmanager:convertToDiffusersHelpText5')}</ListItem>
|
||||
</UnorderedList>
|
||||
<Text>{t('modelmanager:convertToDiffusersHelpText6')}</Text>
|
||||
<Flex flexDir="column" gap={4}>
|
||||
<RadioGroup
|
||||
value={modelType}
|
||||
onChange={(v) => setModelType(v)}
|
||||
defaultValue="1"
|
||||
name="model_type"
|
||||
>
|
||||
<Flex gap={4}>
|
||||
<IAICheckbox
|
||||
checked={isInpainting}
|
||||
onChange={() => {
|
||||
setIsInpainting(!isInpainting);
|
||||
setIsCustomConfig(false);
|
||||
}}
|
||||
label={t('modelmanager:inpaintingModel')}
|
||||
isDisabled={customConfig}
|
||||
/>
|
||||
<IAICheckbox
|
||||
checked={customConfig}
|
||||
onChange={() => {
|
||||
setIsCustomConfig(!customConfig);
|
||||
setIsInpainting(false);
|
||||
}}
|
||||
label={t('modelmanager:customConfig')}
|
||||
isDisabled={isInpainting}
|
||||
/>
|
||||
<Radio value="1">{t('modelmanager:v1')}</Radio>
|
||||
<Radio value="2">{t('modelmanager:v2')}</Radio>
|
||||
<Radio value="inpainting">{t('modelmanager:inpainting')}</Radio>
|
||||
<Radio value="custom">{t('modelmanager:custom')}</Radio>
|
||||
</Flex>
|
||||
{customConfig && (
|
||||
</RadioGroup>
|
||||
{modelType === 'custom' && (
|
||||
<Flex flexDirection="column" rowGap={2}>
|
||||
<Text
|
||||
fontWeight="bold"
|
||||
@ -136,7 +134,6 @@ export default function ModelConvert(props: ModelConvertProps) {
|
||||
</Flex>
|
||||
)}
|
||||
</Flex>
|
||||
</Flex>
|
||||
</IAIAlertDialog>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user