mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat: Add Scan Models Advanced Add
This commit is contained in:
parent
38e6e3b36b
commit
cbd5be73d2
@ -2,10 +2,12 @@ import { PayloadAction, createSlice } from '@reduxjs/toolkit';
|
|||||||
|
|
||||||
type ModelManagerState = {
|
type ModelManagerState = {
|
||||||
searchFolder: string | null;
|
searchFolder: string | null;
|
||||||
|
advancedAddScanModel: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialModelManagerState: ModelManagerState = {
|
const initialModelManagerState: ModelManagerState = {
|
||||||
searchFolder: null,
|
searchFolder: null,
|
||||||
|
advancedAddScanModel: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const modelManagerSlice = createSlice({
|
export const modelManagerSlice = createSlice({
|
||||||
@ -15,9 +17,13 @@ export const modelManagerSlice = createSlice({
|
|||||||
setSearchFolder: (state, action: PayloadAction<string | null>) => {
|
setSearchFolder: (state, action: PayloadAction<string | null>) => {
|
||||||
state.searchFolder = action.payload;
|
state.searchFolder = action.payload;
|
||||||
},
|
},
|
||||||
|
setAdvancedAddScanModel: (state, action: PayloadAction<string | null>) => {
|
||||||
|
state.advancedAddScanModel = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { setSearchFolder } = modelManagerSlice.actions;
|
export const { setSearchFolder, setAdvancedAddScanModel } =
|
||||||
|
modelManagerSlice.actions;
|
||||||
|
|
||||||
export default modelManagerSlice.reducer;
|
export default modelManagerSlice.reducer;
|
||||||
|
@ -10,20 +10,28 @@ 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';
|
||||||
import { CheckpointModelConfig } from 'services/api/types';
|
import { CheckpointModelConfig } from 'services/api/types';
|
||||||
|
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';
|
||||||
|
|
||||||
export default function AdvancedAddCheckpoint() {
|
type AdvancedAddCheckpointProps = {
|
||||||
|
model_path?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function AdvancedAddCheckpoint(
|
||||||
|
props: AdvancedAddCheckpointProps
|
||||||
|
) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
const { model_path } = props;
|
||||||
|
|
||||||
const advancedAddCheckpointForm = useForm<CheckpointModelConfig>({
|
const advancedAddCheckpointForm = useForm<CheckpointModelConfig>({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
model_name: '',
|
model_name: model_path ? model_path.split('\\').splice(-1)[0] : '',
|
||||||
base_model: 'sd-1',
|
base_model: 'sd-1',
|
||||||
model_type: 'main',
|
model_type: 'main',
|
||||||
path: '',
|
path: model_path ? model_path : '',
|
||||||
description: '',
|
description: '',
|
||||||
model_format: 'checkpoint',
|
model_format: 'checkpoint',
|
||||||
error: undefined,
|
error: undefined,
|
||||||
@ -52,6 +60,11 @@ export default function AdvancedAddCheckpoint() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
advancedAddCheckpointForm.reset();
|
advancedAddCheckpointForm.reset();
|
||||||
|
|
||||||
|
// Close Advanced Panel in Scan Models tab
|
||||||
|
if (model_path) {
|
||||||
|
dispatch(setAdvancedAddScanModel(null));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
useGetModelsInFolderQuery,
|
useGetModelsInFolderQuery,
|
||||||
useImportMainModelsMutation,
|
useImportMainModelsMutation,
|
||||||
} from 'services/api/endpoints/models';
|
} from 'services/api/endpoints/models';
|
||||||
|
import { setAdvancedAddScanModel } from '../../store/modelManagerSlice';
|
||||||
|
|
||||||
export default function FoundModelsList() {
|
export default function FoundModelsList() {
|
||||||
const searchFolder = useAppSelector(
|
const searchFolder = useAppSelector(
|
||||||
@ -137,7 +138,12 @@ export default function FoundModelsList() {
|
|||||||
>
|
>
|
||||||
Quick Add
|
Quick Add
|
||||||
</IAIButton>
|
</IAIButton>
|
||||||
<IAIButton>Advanced</IAIButton>
|
<IAIButton
|
||||||
|
onClick={() => dispatch(setAdvancedAddScanModel(model))}
|
||||||
|
isLoading={isLoading}
|
||||||
|
>
|
||||||
|
Advanced
|
||||||
|
</IAIButton>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
))}
|
))}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
import { Box, Flex, Text } from '@chakra-ui/react';
|
||||||
|
import { RootState } from 'app/store/store';
|
||||||
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
|
import IAIIconButton from 'common/components/IAIIconButton';
|
||||||
|
import { motion } from 'framer-motion';
|
||||||
|
import { FaTimes } from 'react-icons/fa';
|
||||||
|
import { setAdvancedAddScanModel } from '../../store/modelManagerSlice';
|
||||||
|
import AdvancedAddCheckpoint from './AdvancedAddCheckpoint';
|
||||||
|
|
||||||
|
export default function ScanAdvancedAddModels() {
|
||||||
|
const advancedAddScanModel = useAppSelector(
|
||||||
|
(state: RootState) => state.modelmanager.advancedAddScanModel
|
||||||
|
);
|
||||||
|
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
return (
|
||||||
|
advancedAddScanModel && (
|
||||||
|
<Box
|
||||||
|
as={motion.div}
|
||||||
|
initial={{ x: -100, opacity: 0 }}
|
||||||
|
animate={{ x: 0, opacity: 1, transition: { duration: 0.2 } }}
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
minWidth: '50%',
|
||||||
|
maxHeight: window.innerHeight - 330,
|
||||||
|
overflow: 'scroll',
|
||||||
|
p: 4,
|
||||||
|
gap: 4,
|
||||||
|
borderRadius: 4,
|
||||||
|
bg: 'base.200',
|
||||||
|
_dark: {
|
||||||
|
bg: 'base.800',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Flex justifyContent="space-between" alignItems="center">
|
||||||
|
<Text size="xl" fontWeight={600}>
|
||||||
|
Add Checkpoint Model
|
||||||
|
</Text>
|
||||||
|
<IAIIconButton
|
||||||
|
icon={<FaTimes />}
|
||||||
|
aria-label="Close Advanced"
|
||||||
|
onClick={() => dispatch(setAdvancedAddScanModel(null))}
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
<AdvancedAddCheckpoint
|
||||||
|
key={advancedAddScanModel}
|
||||||
|
model_path={advancedAddScanModel}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
@ -1,13 +1,24 @@
|
|||||||
import { Flex } from '@chakra-ui/react';
|
import { Flex } from '@chakra-ui/react';
|
||||||
import FoundModelsList from './FoundModelsList';
|
import FoundModelsList from './FoundModelsList';
|
||||||
|
import ScanAdvancedAddModels from './ScanAdvancedAddModels';
|
||||||
import SearchFolderForm from './SearchFolderForm';
|
import SearchFolderForm from './SearchFolderForm';
|
||||||
|
|
||||||
export default function ScanModels() {
|
export default function ScanModels() {
|
||||||
return (
|
return (
|
||||||
<Flex flexDirection="column" w="100%" gap={2}>
|
<Flex flexDirection="column" w="100%" gap={4}>
|
||||||
<SearchFolderForm />
|
<SearchFolderForm />
|
||||||
<Flex sx={{ maxHeight: window.innerHeight - 330, overflow: 'scroll' }}>
|
<Flex gap={4}>
|
||||||
<FoundModelsList />
|
<Flex
|
||||||
|
sx={{
|
||||||
|
maxHeight: window.innerHeight - 330,
|
||||||
|
overflow: 'scroll',
|
||||||
|
gap: 4,
|
||||||
|
w: '100%',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FoundModelsList />
|
||||||
|
</Flex>
|
||||||
|
<ScanAdvancedAddModels />
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user