mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Merge branch 'main' into lama-infill
This commit is contained in:
commit
52d15e06bf
@ -1,11 +1,11 @@
|
|||||||
import { Flex } from '@chakra-ui/react';
|
import { Flex } from '@chakra-ui/react';
|
||||||
import { useForm } from '@mantine/form';
|
import { useForm } from '@mantine/form';
|
||||||
import { makeToast } from 'features/system/util/makeToast';
|
|
||||||
import { useAppDispatch } from 'app/store/storeHooks';
|
import { useAppDispatch } from 'app/store/storeHooks';
|
||||||
import IAIButton from 'common/components/IAIButton';
|
import IAIButton from 'common/components/IAIButton';
|
||||||
import IAIMantineTextInput from 'common/components/IAIMantineInput';
|
import IAIMantineTextInput from 'common/components/IAIMantineInput';
|
||||||
import IAISimpleCheckbox from 'common/components/IAISimpleCheckbox';
|
import IAISimpleCheckbox from 'common/components/IAISimpleCheckbox';
|
||||||
import { addToast } from 'features/system/store/systemSlice';
|
import { addToast } from 'features/system/store/systemSlice';
|
||||||
|
import { makeToast } from 'features/system/util/makeToast';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAddMainModelsMutation } from 'services/api/endpoints/models';
|
import { useAddMainModelsMutation } from 'services/api/endpoints/models';
|
||||||
@ -14,6 +14,7 @@ import { setAdvancedAddScanModel } from '../../store/modelManagerSlice';
|
|||||||
import BaseModelSelect from '../shared/BaseModelSelect';
|
import BaseModelSelect from '../shared/BaseModelSelect';
|
||||||
import CheckpointConfigsSelect from '../shared/CheckpointConfigsSelect';
|
import CheckpointConfigsSelect from '../shared/CheckpointConfigsSelect';
|
||||||
import ModelVariantSelect from '../shared/ModelVariantSelect';
|
import ModelVariantSelect from '../shared/ModelVariantSelect';
|
||||||
|
import { getModelName } from './util';
|
||||||
|
|
||||||
type AdvancedAddCheckpointProps = {
|
type AdvancedAddCheckpointProps = {
|
||||||
model_path?: string;
|
model_path?: string;
|
||||||
@ -28,7 +29,7 @@ export default function AdvancedAddCheckpoint(
|
|||||||
|
|
||||||
const advancedAddCheckpointForm = useForm<CheckpointModelConfig>({
|
const advancedAddCheckpointForm = useForm<CheckpointModelConfig>({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
model_name: model_path?.split('\\').splice(-1)[0]?.split('.')[0] ?? '',
|
model_name: model_path ? getModelName(model_path) : '',
|
||||||
base_model: 'sd-1',
|
base_model: 'sd-1',
|
||||||
model_type: 'main',
|
model_type: 'main',
|
||||||
path: model_path ? model_path : '',
|
path: model_path ? model_path : '',
|
||||||
@ -100,6 +101,17 @@ export default function AdvancedAddCheckpoint(
|
|||||||
label="Model Location"
|
label="Model Location"
|
||||||
required
|
required
|
||||||
{...advancedAddCheckpointForm.getInputProps('path')}
|
{...advancedAddCheckpointForm.getInputProps('path')}
|
||||||
|
onBlur={(e) => {
|
||||||
|
if (advancedAddCheckpointForm.values['model_name'] === '') {
|
||||||
|
const modelName = getModelName(e.currentTarget.value);
|
||||||
|
if (modelName) {
|
||||||
|
advancedAddCheckpointForm.setFieldValue(
|
||||||
|
'model_name',
|
||||||
|
modelName as string
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<IAIMantineTextInput
|
<IAIMantineTextInput
|
||||||
label="Description"
|
label="Description"
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import { Flex } from '@chakra-ui/react';
|
import { Flex } from '@chakra-ui/react';
|
||||||
import { useForm } from '@mantine/form';
|
import { useForm } from '@mantine/form';
|
||||||
import { makeToast } from 'features/system/util/makeToast';
|
|
||||||
import { useAppDispatch } from 'app/store/storeHooks';
|
import { useAppDispatch } from 'app/store/storeHooks';
|
||||||
import IAIButton from 'common/components/IAIButton';
|
import IAIButton from 'common/components/IAIButton';
|
||||||
import IAIMantineTextInput from 'common/components/IAIMantineInput';
|
import IAIMantineTextInput from 'common/components/IAIMantineInput';
|
||||||
import { addToast } from 'features/system/store/systemSlice';
|
import { addToast } from 'features/system/store/systemSlice';
|
||||||
|
import { makeToast } from 'features/system/util/makeToast';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAddMainModelsMutation } from 'services/api/endpoints/models';
|
import { useAddMainModelsMutation } from 'services/api/endpoints/models';
|
||||||
import { DiffusersModelConfig } from 'services/api/types';
|
import { DiffusersModelConfig } from 'services/api/types';
|
||||||
import { setAdvancedAddScanModel } from '../../store/modelManagerSlice';
|
import { setAdvancedAddScanModel } from '../../store/modelManagerSlice';
|
||||||
import BaseModelSelect from '../shared/BaseModelSelect';
|
import BaseModelSelect from '../shared/BaseModelSelect';
|
||||||
import ModelVariantSelect from '../shared/ModelVariantSelect';
|
import ModelVariantSelect from '../shared/ModelVariantSelect';
|
||||||
|
import { getModelName } from './util';
|
||||||
|
|
||||||
type AdvancedAddDiffusersProps = {
|
type AdvancedAddDiffusersProps = {
|
||||||
model_path?: string;
|
model_path?: string;
|
||||||
@ -25,7 +26,7 @@ export default function AdvancedAddDiffusers(props: AdvancedAddDiffusersProps) {
|
|||||||
|
|
||||||
const advancedAddDiffusersForm = useForm<DiffusersModelConfig>({
|
const advancedAddDiffusersForm = useForm<DiffusersModelConfig>({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
model_name: model_path?.split('\\').splice(-1)[0] ?? '',
|
model_name: model_path ? getModelName(model_path, false) : '',
|
||||||
base_model: 'sd-1',
|
base_model: 'sd-1',
|
||||||
model_type: 'main',
|
model_type: 'main',
|
||||||
path: model_path ? model_path : '',
|
path: model_path ? model_path : '',
|
||||||
@ -92,6 +93,17 @@ export default function AdvancedAddDiffusers(props: AdvancedAddDiffusersProps) {
|
|||||||
label="Model Location"
|
label="Model Location"
|
||||||
placeholder="Provide the path to a local folder where your Diffusers Model is stored"
|
placeholder="Provide the path to a local folder where your Diffusers Model is stored"
|
||||||
{...advancedAddDiffusersForm.getInputProps('path')}
|
{...advancedAddDiffusersForm.getInputProps('path')}
|
||||||
|
onBlur={(e) => {
|
||||||
|
if (advancedAddDiffusersForm.values['model_name'] === '') {
|
||||||
|
const modelName = getModelName(e.currentTarget.value, false);
|
||||||
|
if (modelName) {
|
||||||
|
advancedAddDiffusersForm.setFieldValue(
|
||||||
|
'model_name',
|
||||||
|
modelName as string
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<IAIMantineTextInput
|
<IAIMantineTextInput
|
||||||
label="Description"
|
label="Description"
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
export function getModelName(filepath: string, isCheckpoint: boolean = true) {
|
||||||
|
let regex;
|
||||||
|
if (isCheckpoint) {
|
||||||
|
regex = new RegExp('[^\\\\/]+(?=\\.)');
|
||||||
|
} else {
|
||||||
|
regex = new RegExp('[^\\\\/]+(?=[\\\\/]?$)');
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = filepath.match(regex);
|
||||||
|
if (match) {
|
||||||
|
return match[0];
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user