mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Merge branch 'main' into feat/ruff
This commit is contained in:
@ -583,6 +583,7 @@
|
|||||||
"strength": "Image to image strength",
|
"strength": "Image to image strength",
|
||||||
"Threshold": "Noise Threshold",
|
"Threshold": "Noise Threshold",
|
||||||
"variations": "Seed-weight pairs",
|
"variations": "Seed-weight pairs",
|
||||||
|
"vae": "VAE",
|
||||||
"width": "Width",
|
"width": "Width",
|
||||||
"workflow": "Workflow"
|
"workflow": "Workflow"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import { Box, ChakraProps } from '@chakra-ui/react';
|
import { ChakraProps, Flex } from '@chakra-ui/react';
|
||||||
import { memo } from 'react';
|
import { memo, useCallback } from 'react';
|
||||||
import { RgbaColorPicker } from 'react-colorful';
|
import { RgbaColorPicker } from 'react-colorful';
|
||||||
import { ColorPickerBaseProps, RgbaColor } from 'react-colorful/dist/types';
|
import { ColorPickerBaseProps, RgbaColor } from 'react-colorful/dist/types';
|
||||||
|
import IAINumberInput from './IAINumberInput';
|
||||||
|
|
||||||
type IAIColorPickerProps = ColorPickerBaseProps<RgbaColor>;
|
type IAIColorPickerProps = ColorPickerBaseProps<RgbaColor> & {
|
||||||
|
withNumberInput?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
const colorPickerStyles: NonNullable<ChakraProps['sx']> = {
|
const colorPickerStyles: NonNullable<ChakraProps['sx']> = {
|
||||||
width: 6,
|
width: 6,
|
||||||
@ -11,17 +14,84 @@ const colorPickerStyles: NonNullable<ChakraProps['sx']> = {
|
|||||||
borderColor: 'base.100',
|
borderColor: 'base.100',
|
||||||
};
|
};
|
||||||
|
|
||||||
const sx = {
|
const sx: ChakraProps['sx'] = {
|
||||||
'.react-colorful__hue-pointer': colorPickerStyles,
|
'.react-colorful__hue-pointer': colorPickerStyles,
|
||||||
'.react-colorful__saturation-pointer': colorPickerStyles,
|
'.react-colorful__saturation-pointer': colorPickerStyles,
|
||||||
'.react-colorful__alpha-pointer': colorPickerStyles,
|
'.react-colorful__alpha-pointer': colorPickerStyles,
|
||||||
|
gap: 2,
|
||||||
|
flexDir: 'column',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const numberInputWidth: ChakraProps['w'] = '4.2rem';
|
||||||
|
|
||||||
const IAIColorPicker = (props: IAIColorPickerProps) => {
|
const IAIColorPicker = (props: IAIColorPickerProps) => {
|
||||||
|
const { color, onChange, withNumberInput, ...rest } = props;
|
||||||
|
const handleChangeR = useCallback(
|
||||||
|
(r: number) => onChange({ ...color, r }),
|
||||||
|
[color, onChange]
|
||||||
|
);
|
||||||
|
const handleChangeG = useCallback(
|
||||||
|
(g: number) => onChange({ ...color, g }),
|
||||||
|
[color, onChange]
|
||||||
|
);
|
||||||
|
const handleChangeB = useCallback(
|
||||||
|
(b: number) => onChange({ ...color, b }),
|
||||||
|
[color, onChange]
|
||||||
|
);
|
||||||
|
const handleChangeA = useCallback(
|
||||||
|
(a: number) => onChange({ ...color, a }),
|
||||||
|
[color, onChange]
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<Box sx={sx}>
|
<Flex sx={sx}>
|
||||||
<RgbaColorPicker {...props} />
|
<RgbaColorPicker
|
||||||
</Box>
|
color={color}
|
||||||
|
onChange={onChange}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
{...rest}
|
||||||
|
/>
|
||||||
|
{withNumberInput && (
|
||||||
|
<Flex>
|
||||||
|
<IAINumberInput
|
||||||
|
value={color.r}
|
||||||
|
onChange={handleChangeR}
|
||||||
|
min={0}
|
||||||
|
max={255}
|
||||||
|
step={1}
|
||||||
|
label="Red"
|
||||||
|
w={numberInputWidth}
|
||||||
|
/>
|
||||||
|
<IAINumberInput
|
||||||
|
value={color.g}
|
||||||
|
onChange={handleChangeG}
|
||||||
|
min={0}
|
||||||
|
max={255}
|
||||||
|
step={1}
|
||||||
|
label="Green"
|
||||||
|
w={numberInputWidth}
|
||||||
|
/>
|
||||||
|
<IAINumberInput
|
||||||
|
value={color.b}
|
||||||
|
onChange={handleChangeB}
|
||||||
|
min={0}
|
||||||
|
max={255}
|
||||||
|
step={1}
|
||||||
|
label="Blue"
|
||||||
|
w={numberInputWidth}
|
||||||
|
/>
|
||||||
|
<IAINumberInput
|
||||||
|
value={color.a}
|
||||||
|
onChange={handleChangeA}
|
||||||
|
step={0.1}
|
||||||
|
min={0}
|
||||||
|
max={1}
|
||||||
|
label="Alpha"
|
||||||
|
w={numberInputWidth}
|
||||||
|
isInteger={false}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
)}
|
||||||
|
</Flex>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -245,6 +245,7 @@ const IAICanvasToolChooserOptions = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IAIColorPicker
|
<IAIColorPicker
|
||||||
|
withNumberInput={true}
|
||||||
color={brushColor}
|
color={brushColor}
|
||||||
onChange={(newColor) => dispatch(setBrushColor(newColor))}
|
onChange={(newColor) => dispatch(setBrushColor(newColor))}
|
||||||
/>
|
/>
|
||||||
|
@ -31,6 +31,7 @@ const ImageMetadataActions = (props: Props) => {
|
|||||||
recallCfgScale,
|
recallCfgScale,
|
||||||
recallModel,
|
recallModel,
|
||||||
recallScheduler,
|
recallScheduler,
|
||||||
|
recallVaeModel,
|
||||||
recallSteps,
|
recallSteps,
|
||||||
recallWidth,
|
recallWidth,
|
||||||
recallHeight,
|
recallHeight,
|
||||||
@ -72,6 +73,10 @@ const ImageMetadataActions = (props: Props) => {
|
|||||||
recallScheduler(metadata?.scheduler);
|
recallScheduler(metadata?.scheduler);
|
||||||
}, [metadata?.scheduler, recallScheduler]);
|
}, [metadata?.scheduler, recallScheduler]);
|
||||||
|
|
||||||
|
const handleRecallVaeModel = useCallback(() => {
|
||||||
|
recallVaeModel(metadata?.vae);
|
||||||
|
}, [metadata?.vae, recallVaeModel]);
|
||||||
|
|
||||||
const handleRecallSteps = useCallback(() => {
|
const handleRecallSteps = useCallback(() => {
|
||||||
recallSteps(metadata?.steps);
|
recallSteps(metadata?.steps);
|
||||||
}, [metadata?.steps, recallSteps]);
|
}, [metadata?.steps, recallSteps]);
|
||||||
@ -219,6 +224,11 @@ const ImageMetadataActions = (props: Props) => {
|
|||||||
onClick={handleRecallScheduler}
|
onClick={handleRecallScheduler}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
<ImageMetadataItem
|
||||||
|
label={t('metadata.vae')}
|
||||||
|
value={metadata.vae?.model_name ?? 'Default'}
|
||||||
|
onClick={handleRecallVaeModel}
|
||||||
|
/>
|
||||||
{metadata.steps && (
|
{metadata.steps && (
|
||||||
<ImageMetadataItem
|
<ImageMetadataItem
|
||||||
label={t('metadata.steps')}
|
label={t('metadata.steps')}
|
||||||
|
@ -36,6 +36,7 @@ import {
|
|||||||
setRefinerStart,
|
setRefinerStart,
|
||||||
setRefinerSteps,
|
setRefinerSteps,
|
||||||
} from 'features/sdxl/store/sdxlSlice';
|
} from 'features/sdxl/store/sdxlSlice';
|
||||||
|
import { isNil } from 'lodash-es';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { ImageDTO } from 'services/api/types';
|
import { ImageDTO } from 'services/api/types';
|
||||||
@ -65,8 +66,10 @@ import {
|
|||||||
setSeed,
|
setSeed,
|
||||||
setSteps,
|
setSteps,
|
||||||
setWidth,
|
setWidth,
|
||||||
|
vaeSelected,
|
||||||
} from '../store/generationSlice';
|
} from '../store/generationSlice';
|
||||||
import {
|
import {
|
||||||
|
isValidBoolean,
|
||||||
isValidCfgScale,
|
isValidCfgScale,
|
||||||
isValidControlNetModel,
|
isValidControlNetModel,
|
||||||
isValidHeight,
|
isValidHeight,
|
||||||
@ -86,8 +89,8 @@ import {
|
|||||||
isValidSeed,
|
isValidSeed,
|
||||||
isValidSteps,
|
isValidSteps,
|
||||||
isValidStrength,
|
isValidStrength,
|
||||||
|
isValidVaeModel,
|
||||||
isValidWidth,
|
isValidWidth,
|
||||||
isValidBoolean,
|
|
||||||
} from '../types/parameterSchemas';
|
} from '../types/parameterSchemas';
|
||||||
|
|
||||||
const selector = createSelector(
|
const selector = createSelector(
|
||||||
@ -306,6 +309,25 @@ export const useRecallParameters = () => {
|
|||||||
[dispatch, parameterSetToast, parameterNotSetToast]
|
[dispatch, parameterSetToast, parameterNotSetToast]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recall vae model
|
||||||
|
*/
|
||||||
|
const recallVaeModel = useCallback(
|
||||||
|
(vae: unknown) => {
|
||||||
|
if (!isValidVaeModel(vae) && !isNil(vae)) {
|
||||||
|
parameterNotSetToast();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isNil(vae)) {
|
||||||
|
dispatch(vaeSelected(null));
|
||||||
|
} else {
|
||||||
|
dispatch(vaeSelected(vae));
|
||||||
|
}
|
||||||
|
parameterSetToast();
|
||||||
|
},
|
||||||
|
[dispatch, parameterSetToast, parameterNotSetToast]
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recall steps with toast
|
* Recall steps with toast
|
||||||
*/
|
*/
|
||||||
@ -757,6 +779,7 @@ export const useRecallParameters = () => {
|
|||||||
positive_prompt,
|
positive_prompt,
|
||||||
negative_prompt,
|
negative_prompt,
|
||||||
scheduler,
|
scheduler,
|
||||||
|
vae,
|
||||||
seed,
|
seed,
|
||||||
steps,
|
steps,
|
||||||
width,
|
width,
|
||||||
@ -798,6 +821,13 @@ export const useRecallParameters = () => {
|
|||||||
if (isValidScheduler(scheduler)) {
|
if (isValidScheduler(scheduler)) {
|
||||||
dispatch(setScheduler(scheduler));
|
dispatch(setScheduler(scheduler));
|
||||||
}
|
}
|
||||||
|
if (isValidVaeModel(vae) || isNil(vae)) {
|
||||||
|
if (isNil(vae)) {
|
||||||
|
dispatch(vaeSelected(null));
|
||||||
|
} else {
|
||||||
|
dispatch(vaeSelected(vae));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isValidSeed(seed)) {
|
if (isValidSeed(seed)) {
|
||||||
dispatch(setSeed(seed));
|
dispatch(setSeed(seed));
|
||||||
@ -932,6 +962,7 @@ export const useRecallParameters = () => {
|
|||||||
recallCfgScale,
|
recallCfgScale,
|
||||||
recallModel,
|
recallModel,
|
||||||
recallScheduler,
|
recallScheduler,
|
||||||
|
recallVaeModel,
|
||||||
recallSteps,
|
recallSteps,
|
||||||
recallWidth,
|
recallWidth,
|
||||||
recallHeight,
|
recallHeight,
|
||||||
|
Reference in New Issue
Block a user