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(
|
original_config_file = Path(
|
||||||
Globals.root, original_config_file)
|
Globals.root, original_config_file)
|
||||||
|
|
||||||
if model_to_convert['is_inpainting']:
|
if model_to_convert['model_type'] == 'inpainting':
|
||||||
original_config_file = Path(
|
original_config_file = Path(
|
||||||
'configs',
|
'configs',
|
||||||
'stable-diffusion',
|
'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(
|
original_config_file = Path(
|
||||||
model_to_convert['custom_config'])
|
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.",
|
"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.",
|
"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?",
|
"convertToDiffusersHelpText6": "Do you wish to convert this model?",
|
||||||
"inpaintingModel": "Inpainting Model",
|
"v1": "v1",
|
||||||
"customConfig": "Custom Config",
|
"v2": "v2",
|
||||||
|
"inpainting": "v1 Inpainting",
|
||||||
|
"custom": "Custom",
|
||||||
"pathToCustomConfig": "Path To Custom Config",
|
"pathToCustomConfig": "Path To Custom Config",
|
||||||
"statusConverting": "Converting"
|
"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 = {
|
export declare type InvokeModelConversionProps = {
|
||||||
name: string;
|
name: string;
|
||||||
is_inpainting: boolean;
|
model_type: string;
|
||||||
custom_config: string | null;
|
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 { convertToDiffusers } from 'app/socketio/actions';
|
||||||
import { RootState } from 'app/store';
|
import { RootState } from 'app/store';
|
||||||
import { useAppDispatch, useAppSelector } from 'app/storeHooks';
|
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 IAICheckbox from 'common/components/IAICheckbox';
|
|
||||||
import IAIInput from 'common/components/IAIInput';
|
import IAIInput from 'common/components/IAIInput';
|
||||||
import { setIsProcessing } from 'features/system/store/systemSlice';
|
import { setIsProcessing } from 'features/system/store/systemSlice';
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
@ -23,9 +29,8 @@ export default function ModelConvert(props: ModelConvertProps) {
|
|||||||
|
|
||||||
const retrievedModel = model_list[model];
|
const retrievedModel = model_list[model];
|
||||||
|
|
||||||
const [isInpainting, setIsInpainting] = useState<boolean>(false);
|
|
||||||
const [customConfig, setIsCustomConfig] = useState<boolean>(false);
|
|
||||||
const [pathToConfig, setPathToConfig] = useState<string>('');
|
const [pathToConfig, setPathToConfig] = useState<string>('');
|
||||||
|
const [modelType, setModelType] = useState<string>('1');
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { t } = useTranslation();
|
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.
|
// Need to manually handle local state reset because the component does not re-render.
|
||||||
const stateReset = () => {
|
const stateReset = () => {
|
||||||
setIsInpainting(false);
|
setModelType('1');
|
||||||
setIsCustomConfig(false);
|
|
||||||
setPathToConfig('');
|
setPathToConfig('');
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,8 +62,9 @@ export default function ModelConvert(props: ModelConvertProps) {
|
|||||||
const modelConvertHandler = () => {
|
const modelConvertHandler = () => {
|
||||||
const modelConvertData = {
|
const modelConvertData = {
|
||||||
name: model,
|
name: model,
|
||||||
is_inpainting: isInpainting,
|
model_type: modelType,
|
||||||
custom_config: customConfig && pathToConfig !== '' ? pathToConfig : null,
|
custom_config:
|
||||||
|
modelType === 'custom' && pathToConfig !== '' ? pathToConfig : null,
|
||||||
};
|
};
|
||||||
|
|
||||||
dispatch(setIsProcessing(true));
|
dispatch(setIsProcessing(true));
|
||||||
@ -86,6 +91,7 @@ export default function ModelConvert(props: ModelConvertProps) {
|
|||||||
🧨 {t('modelmanager:convertToDiffusers')}
|
🧨 {t('modelmanager:convertToDiffusers')}
|
||||||
</IAIButton>
|
</IAIButton>
|
||||||
}
|
}
|
||||||
|
motionPreset="slideInBottom"
|
||||||
>
|
>
|
||||||
<Flex flexDirection="column" rowGap={4}>
|
<Flex flexDirection="column" rowGap={4}>
|
||||||
<Text>{t('modelmanager:convertToDiffusersHelpText1')}</Text>
|
<Text>{t('modelmanager:convertToDiffusersHelpText1')}</Text>
|
||||||
@ -96,46 +102,37 @@ export default function ModelConvert(props: ModelConvertProps) {
|
|||||||
<ListItem>{t('modelmanager:convertToDiffusersHelpText5')}</ListItem>
|
<ListItem>{t('modelmanager:convertToDiffusersHelpText5')}</ListItem>
|
||||||
</UnorderedList>
|
</UnorderedList>
|
||||||
<Text>{t('modelmanager:convertToDiffusersHelpText6')}</Text>
|
<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}>
|
<Flex gap={4}>
|
||||||
<IAICheckbox
|
<Radio value="1">{t('modelmanager:v1')}</Radio>
|
||||||
checked={isInpainting}
|
<Radio value="2">{t('modelmanager:v2')}</Radio>
|
||||||
onChange={() => {
|
<Radio value="inpainting">{t('modelmanager:inpainting')}</Radio>
|
||||||
setIsInpainting(!isInpainting);
|
<Radio value="custom">{t('modelmanager:custom')}</Radio>
|
||||||
setIsCustomConfig(false);
|
</Flex>
|
||||||
|
</RadioGroup>
|
||||||
|
{modelType === 'custom' && (
|
||||||
|
<Flex flexDirection="column" rowGap={2}>
|
||||||
|
<Text
|
||||||
|
fontWeight="bold"
|
||||||
|
fontSize="sm"
|
||||||
|
color="var(--text-color-secondary)"
|
||||||
|
>
|
||||||
|
{t('modelmanager:pathToCustomConfig')}
|
||||||
|
</Text>
|
||||||
|
<IAIInput
|
||||||
|
value={pathToConfig}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (e.target.value !== '') setPathToConfig(e.target.value);
|
||||||
}}
|
}}
|
||||||
label={t('modelmanager:inpaintingModel')}
|
width="25rem"
|
||||||
isDisabled={customConfig}
|
|
||||||
/>
|
|
||||||
<IAICheckbox
|
|
||||||
checked={customConfig}
|
|
||||||
onChange={() => {
|
|
||||||
setIsCustomConfig(!customConfig);
|
|
||||||
setIsInpainting(false);
|
|
||||||
}}
|
|
||||||
label={t('modelmanager:customConfig')}
|
|
||||||
isDisabled={isInpainting}
|
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
{customConfig && (
|
)}
|
||||||
<Flex flexDirection="column" rowGap={2}>
|
|
||||||
<Text
|
|
||||||
fontWeight="bold"
|
|
||||||
fontSize="sm"
|
|
||||||
color="var(--text-color-secondary)"
|
|
||||||
>
|
|
||||||
{t('modelmanager:pathToCustomConfig')}
|
|
||||||
</Text>
|
|
||||||
<IAIInput
|
|
||||||
value={pathToConfig}
|
|
||||||
onChange={(e) => {
|
|
||||||
if (e.target.value !== '') setPathToConfig(e.target.value);
|
|
||||||
}}
|
|
||||||
width="25rem"
|
|
||||||
/>
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</IAIAlertDialog>
|
</IAIAlertDialog>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user