Skip to content

Commit c91ba2d

Browse files
feat: Infer Model Name automatically if empty in Model Forms
1 parent b0cce80 commit c91ba2d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/AddModelsPanel/AdvancedAddCheckpoint.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Flex } from '@chakra-ui/react';
22
import { useForm } from '@mantine/form';
3-
import { makeToast } from 'features/system/util/makeToast';
43
import { useAppDispatch } from 'app/store/storeHooks';
54
import IAIButton from 'common/components/IAIButton';
65
import IAIMantineTextInput from 'common/components/IAIMantineInput';
76
import IAISimpleCheckbox from 'common/components/IAISimpleCheckbox';
87
import { addToast } from 'features/system/store/systemSlice';
8+
import { makeToast } from 'features/system/util/makeToast';
99
import { useState } from 'react';
1010
import { useTranslation } from 'react-i18next';
1111
import { useAddMainModelsMutation } from 'services/api/endpoints/models';
@@ -100,6 +100,17 @@ export default function AdvancedAddCheckpoint(
100100
label="Model Location"
101101
required
102102
{...advancedAddCheckpointForm.getInputProps('path')}
103+
onBlur={(e) => {
104+
if (advancedAddCheckpointForm.values['model_name'] === '') {
105+
advancedAddCheckpointForm.setFieldValue(
106+
'model_name',
107+
e.currentTarget.value
108+
.split('\\')
109+
.splice(-1)[0]
110+
?.split('.')[0] as string
111+
);
112+
}
113+
}}
103114
/>
104115
<IAIMantineTextInput
105116
label="Description"

invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/AddModelsPanel/AdvancedAddDiffusers.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Flex } from '@chakra-ui/react';
22
import { useForm } from '@mantine/form';
3-
import { makeToast } from 'features/system/util/makeToast';
43
import { useAppDispatch } from 'app/store/storeHooks';
54
import IAIButton from 'common/components/IAIButton';
65
import IAIMantineTextInput from 'common/components/IAIMantineInput';
76
import { addToast } from 'features/system/store/systemSlice';
7+
import { makeToast } from 'features/system/util/makeToast';
88
import { useTranslation } from 'react-i18next';
99
import { useAddMainModelsMutation } from 'services/api/endpoints/models';
1010
import { DiffusersModelConfig } from 'services/api/types';
@@ -92,6 +92,14 @@ export default function AdvancedAddDiffusers(props: AdvancedAddDiffusersProps) {
9292
label="Model Location"
9393
placeholder="Provide the path to a local folder where your Diffusers Model is stored"
9494
{...advancedAddDiffusersForm.getInputProps('path')}
95+
onBlur={(e) => {
96+
if (advancedAddDiffusersForm.values['model_name'] === '') {
97+
advancedAddDiffusersForm.setFieldValue(
98+
'model_name',
99+
e.currentTarget.value.split('\\').splice(-1)[0] as string
100+
);
101+
}
102+
}}
95103
/>
96104
<IAIMantineTextInput
97105
label="Description"

0 commit comments

Comments
 (0)