all the lints

This commit is contained in:
Mary Hipp
2024-09-12 11:04:12 -04:00
committed by psychedelicious
parent a300b6ebdd
commit 4b916d217b
23 changed files with 78 additions and 76 deletions

View File

@@ -11,6 +11,7 @@ import {
stagingAreaStartedStaging,
} from 'features/controlLayers/store/canvasStagingAreaSlice';
import { prepareLinearUIBatch } from 'features/nodes/util/graph/buildLinearBatchConfig';
import { buildFLUXGraph } from 'features/nodes/util/graph/generation/buildFLUXGraph';
import { buildSD1Graph } from 'features/nodes/util/graph/generation/buildSD1Graph';
import { buildSDXLGraph } from 'features/nodes/util/graph/generation/buildSDXLGraph';
import type { Graph } from 'features/nodes/util/graph/generation/Graph';
@@ -18,7 +19,6 @@ import { serializeError } from 'serialize-error';
import { queueApi } from 'services/api/endpoints/queue';
import type { Invocation } from 'services/api/types';
import { assert } from 'tsafe';
import { buildFLUXGraph } from '../../../../../features/nodes/util/graph/generation/buildFLUXGraph';
const log = logger('generation');
@@ -48,7 +48,11 @@ export const addEnqueueRequestedLinear = (startAppListening: AppStartListening)
};
let buildGraphResult: Result<
{ g: Graph; noise: Invocation<'noise' | 'flux_denoise'>; posCond: Invocation<'compel' | 'sdxl_compel_prompt' | 'flux_text_encoder'> },
{
g: Graph;
noise: Invocation<'noise' | 'flux_denoise'>;
posCond: Invocation<'compel' | 'sdxl_compel_prompt' | 'flux_text_encoder'>;
},
Error
>;

View File

@@ -10,7 +10,14 @@ import {
rgIPAdapterModelChanged,
} from 'features/controlLayers/store/canvasSlice';
import { loraDeleted } from 'features/controlLayers/store/lorasSlice';
import { clipEmbedModelSelected, fluxVAESelected, modelChanged, refinerModelChanged, t5EncoderModelSelected, vaeSelected } from 'features/controlLayers/store/paramsSlice';
import {
clipEmbedModelSelected,
fluxVAESelected,
modelChanged,
refinerModelChanged,
t5EncoderModelSelected,
vaeSelected,
} from 'features/controlLayers/store/paramsSlice';
import { selectCanvasSlice } from 'features/controlLayers/store/selectors';
import { getEntityIdentifier } from 'features/controlLayers/store/types';
import { calculateNewSize } from 'features/parameters/components/Bbox/calculateNewSize';
@@ -31,7 +38,6 @@ import {
isRefinerMainModelModelConfig,
isSpandrelImageToImageModelConfig,
isT5EncoderModelConfig,
isVAEModelConfig,
} from 'services/api/types';
const log = logger('models');
@@ -54,9 +60,9 @@ export const addModelsLoadedListener = (startAppListening: AppStartListening) =>
handleControlAdapterModels(models, state, dispatch, log);
handleSpandrelImageToImageModels(models, state, dispatch, log);
handleIPAdapterModels(models, state, dispatch, log);
handleT5EncoderModels(models, state, dispatch, log)
handleCLIPEmbedModels(models, state, dispatch, log)
handleFLUXVAEModels(models, state, dispatch, log)
handleT5EncoderModels(models, state, dispatch, log);
handleCLIPEmbedModels(models, state, dispatch, log);
handleFLUXVAEModels(models, state, dispatch, log);
},
});
};

View File

@@ -115,8 +115,8 @@ export type AppConfig = {
};
};
flux: {
guidance: NumericalParameterConfig
}
guidance: NumericalParameterConfig;
};
};
export type PartialAppConfig = O.Partial<AppConfig, 'deep'>;

View File

@@ -148,7 +148,6 @@ const createSelector = (
}
if (model?.base === 'flux') {
console.log({ params })
if (!params.t5EncoderModel) {
reasons.push({ content: i18n.t('parameters.invoke.noT5EncoderModelSelected') });
}

View File

@@ -7,6 +7,8 @@ import type {
ParameterCanvasCoherenceMode,
ParameterCFGRescaleMultiplier,
ParameterCFGScale,
ParameterCLIPEmbedModel,
ParameterGuidance,
ParameterMaskBlurMethod,
ParameterModel,
ParameterNegativePrompt,
@@ -19,10 +21,8 @@ import type {
ParameterSeed,
ParameterSteps,
ParameterStrength,
ParameterVAEModel,
ParameterGuidance,
ParameterT5EncoderModel,
ParameterCLIPEmbedModel
ParameterVAEModel,
} from 'features/parameters/types/parameterSchemas';
import { clamp } from 'lodash-es';
@@ -65,8 +65,8 @@ export type ParamsState = {
refinerPositiveAestheticScore: number;
refinerNegativeAestheticScore: number;
refinerStart: number;
t5EncoderModel: ParameterT5EncoderModel | null,
clipEmbedModel: ParameterCLIPEmbedModel | null
t5EncoderModel: ParameterT5EncoderModel | null;
clipEmbedModel: ParameterCLIPEmbedModel | null;
};
const initialState: ParamsState = {
@@ -109,7 +109,7 @@ const initialState: ParamsState = {
refinerNegativeAestheticScore: 2.5,
refinerStart: 0.8,
t5EncoderModel: null,
clipEmbedModel: null
clipEmbedModel: null,
};
export const paramsSlice = createSlice({

View File

@@ -202,5 +202,5 @@ export const recallers = {
vae: recallVAE,
lora: recallLoRA,
loras: recallAllLoRAs,
t5EncoderModel: recallT5Encoder
t5EncoderModel: recallT5Encoder,
} as const;

View File

@@ -7,7 +7,11 @@ import type {
T2IAdapterConfigMetadata,
} from 'features/metadata/types';
import { InvalidModelConfigError } from 'features/metadata/util/modelFetchingHelpers';
import type { ParameterSDXLRefinerModel, ParameterT5EncoderModel, ParameterVAEModel } from 'features/parameters/types/parameterSchemas';
import type {
ParameterSDXLRefinerModel,
ParameterT5EncoderModel,
ParameterVAEModel,
} from 'features/parameters/types/parameterSchemas';
import type { BaseModelType } from 'services/api/types';
/**

View File

@@ -30,9 +30,10 @@ export const addImageToImage = async (
...scaledSize,
});
const i2l = vaeSource.type === "flux_model_loader" ?
g.addNode({ id: 'flux_vae_encode', type: 'flux_vae_encode' }) :
g.addNode({ id: 'i2l', type: 'i2l', fp32 });
const i2l =
vaeSource.type === 'flux_model_loader'
? g.addNode({ id: 'flux_vae_encode', type: 'flux_vae_encode' })
: g.addNode({ id: 'i2l', type: 'i2l', fp32 });
const resizeImageToOriginalSize = g.addNode({
type: 'img_resize',
@@ -49,7 +50,10 @@ export const addImageToImage = async (
return resizeImageToOriginalSize;
} else {
// No need to resize, just decode
const i2l = vaeSource.type === "flux_model_loader" ? g.addNode({ id: 'flux_vae_encode', type: 'flux_vae_encode' }) : g.addNode({ id: 'i2l', type: 'i2l', fp32 });
const i2l =
vaeSource.type === 'flux_model_loader'
? g.addNode({ id: 'flux_vae_encode', type: 'flux_vae_encode' })
: g.addNode({ id: 'i2l', type: 'i2l', fp32 });
g.addEdge(vaeSource, 'vae', i2l, 'vae');
g.addEdge(i2l, 'latents', denoise, 'latents');
return l2i;

View File

@@ -84,7 +84,7 @@ export const addInpaint = async (
g.addEdge(vaeSource, 'vae', i2l, 'vae');
g.addEdge(vaeSource, 'vae', createGradientMask, 'vae');
if (modelLoader.type !== "flux_model_loader") {
if (modelLoader.type !== 'flux_model_loader') {
g.addEdge(modelLoader, 'unet', createGradientMask, 'unet');
}
g.addEdge(resizeImageToScaledSize, 'image', createGradientMask, 'image');
@@ -140,7 +140,7 @@ export const addInpaint = async (
g.addEdge(i2l, 'latents', denoise, 'latents');
g.addEdge(vaeSource, 'vae', i2l, 'vae');
g.addEdge(vaeSource, 'vae', createGradientMask, 'vae');
if (modelLoader.type !== "flux_model_loader") {
if (modelLoader.type !== 'flux_model_loader') {
g.addEdge(modelLoader, 'unet', createGradientMask, 'unet');
}
g.addEdge(createGradientMask, 'denoise_mask', denoise, 'denoise_mask');

View File

@@ -10,7 +10,9 @@ import type { Invocation } from 'services/api/types';
*/
export const addNSFWChecker = (
g: Graph,
imageOutput: Invocation<'l2i' | 'img_nsfw' | 'img_watermark' | 'img_resize' | 'canvas_v2_mask_and_crop' | 'flux_vae_decode'>
imageOutput: Invocation<
'l2i' | 'img_nsfw' | 'img_watermark' | 'img_resize' | 'canvas_v2_mask_and_crop' | 'flux_vae_decode'
>
): Invocation<'img_nsfw'> => {
const nsfw = g.addNode({
type: 'img_nsfw',

View File

@@ -86,7 +86,7 @@ export const addOutpaint = async (
g.addEdge(infill, 'image', createGradientMask, 'image');
g.addEdge(resizeInputMaskToScaledSize, 'image', createGradientMask, 'mask');
g.addEdge(vaeSource, 'vae', createGradientMask, 'vae');
if (modelLoader.type !== "flux_model_loader") {
if (modelLoader.type !== 'flux_model_loader') {
g.addEdge(modelLoader, 'unet', createGradientMask, 'unet');
}
@@ -172,7 +172,7 @@ export const addOutpaint = async (
g.addEdge(i2l, 'latents', denoise, 'latents');
g.addEdge(vaeSource, 'vae', i2l, 'vae');
g.addEdge(vaeSource, 'vae', createGradientMask, 'vae');
if (modelLoader.type !== "flux_model_loader") {
if (modelLoader.type !== 'flux_model_loader') {
g.addEdge(modelLoader, 'unet', createGradientMask, 'unet');
}

View File

@@ -10,7 +10,9 @@ import type { Invocation } from 'services/api/types';
*/
export const addWatermarker = (
g: Graph,
imageOutput: Invocation<'l2i' | 'img_nsfw' | 'img_watermark' | 'img_resize' | 'canvas_v2_mask_and_crop' | 'flux_vae_decode'>
imageOutput: Invocation<
'l2i' | 'img_nsfw' | 'img_watermark' | 'img_resize' | 'canvas_v2_mask_and_crop' | 'flux_vae_decode'
>
): Invocation<'img_watermark'> => {
const watermark = g.addNode({
type: 'img_watermark',

View File

@@ -35,23 +35,14 @@ export const buildFLUXGraph = async (
const { originalSize, scaledSize } = getSizes(bbox);
const {
model,
guidance,
seed,
steps,
fluxVAE,
t5EncoderModel,
clipEmbedModel,
img2imgStrength,
} = params;
const { model, guidance, seed, steps, fluxVAE, t5EncoderModel, clipEmbedModel, img2imgStrength } = params;
assert(model, 'No model found in state');
assert(t5EncoderModel, 'No T5 Encoder model found in state');
assert(clipEmbedModel, 'No CLIP Embed model found in state');
assert(fluxVAE, 'No FLUX VAE model found in state');
const { positivePrompt, } = getPresetModifiedPrompts(state);
const { positivePrompt } = getPresetModifiedPrompts(state);
const g = new Graph(getPrefixedId('flux_graph'));
const modelLoader = g.addNode({
@@ -60,7 +51,7 @@ export const buildFLUXGraph = async (
model,
t5_encoder_model: t5EncoderModel,
clip_embed_model: clipEmbedModel,
vae_model: fluxVAE
vae_model: fluxVAE,
});
const posCond = g.addNode({
@@ -78,7 +69,7 @@ export const buildFLUXGraph = async (
denoising_start: 1 - img2imgStrength,
denoising_end: 1,
width: scaledSize.width,
height: scaledSize.height
height: scaledSize.height,
});
const l2i = g.addNode({
@@ -86,8 +77,9 @@ export const buildFLUXGraph = async (
id: getPrefixedId('flux_vae_decode'),
});
let canvasOutput: Invocation<'l2i' | 'img_nsfw' | 'img_watermark' | 'img_resize' | 'canvas_v2_mask_and_crop' | 'flux_vae_decode'> = l2i;
let canvasOutput: Invocation<
'l2i' | 'img_nsfw' | 'img_watermark' | 'img_resize' | 'canvas_v2_mask_and_crop' | 'flux_vae_decode'
> = l2i;
g.addEdge(modelLoader, 'transformer', noise, 'transformer');
g.addEdge(modelLoader, 'vae', l2i, 'vae');
@@ -100,7 +92,6 @@ export const buildFLUXGraph = async (
g.addEdge(noise, 'latents', l2i, 'latents');
const modelConfig = await fetchModelConfigWithTypeGuard(model.key, isNonRefinerMainModelConfig);
assert(modelConfig.base === 'flux');
@@ -115,10 +106,9 @@ export const buildFLUXGraph = async (
steps,
vae: fluxVAE,
t5_encoder: t5EncoderModel,
clip_embed_model: clipEmbedModel
clip_embed_model: clipEmbedModel,
});
if (generationMode === 'txt2img') {
canvasOutput = addTextToImage(g, l2i, originalSize, scaledSize);
} else if (generationMode === 'img2img') {
@@ -164,7 +154,6 @@ export const buildFLUXGraph = async (
);
}
if (state.system.shouldUseNSFWChecker) {
canvasOutput = addNSFWChecker(g, canvasOutput);
}

View File

@@ -114,13 +114,13 @@ export const buildSD1Graph = async (
const vaeLoader =
vae?.base === model.base
? g.addNode({
type: 'vae_loader',
id: getPrefixedId('vae'),
vae_model: vae,
})
type: 'vae_loader',
id: getPrefixedId('vae'),
vae_model: vae,
})
: null;
let canvasOutput: Invocation<'l2i' | 'img_nsfw' | 'img_watermark' | 'img_resize' | 'canvas_v2_mask_and_crop'> = l2i;
let canvasOutput: Invocation<'l2i' | 'img_nsfw' | 'img_watermark' | 'img_resize' | 'canvas_v2_mask_and_crop' | 'flux_vae_decode'> = l2i;
g.addEdge(modelLoader, 'unet', denoise, 'unet');
g.addEdge(modelLoader, 'clip', clipSkip, 'clip');

View File

@@ -112,13 +112,13 @@ export const buildSDXLGraph = async (
const vaeLoader =
vae?.base === model.base
? g.addNode({
type: 'vae_loader',
id: getPrefixedId('vae'),
vae_model: vae,
})
type: 'vae_loader',
id: getPrefixedId('vae'),
vae_model: vae,
})
: null;
let canvasOutput: Invocation<'l2i' | 'img_nsfw' | 'img_watermark' | 'img_resize' | 'canvas_v2_mask_and_crop'> = l2i;
let canvasOutput: Invocation<'l2i' | 'img_nsfw' | 'img_watermark' | 'img_resize' | 'canvas_v2_mask_and_crop' | 'flux_vae_decode'> = l2i;
g.addEdge(modelLoader, 'unet', denoise, 'unet');
g.addEdge(modelLoader, 'clip', posCond, 'clip');

View File

@@ -1,12 +1,12 @@
import { Combobox, FormControl, FormLabel } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { useModelCombobox } from 'common/hooks/useModelCombobox';
import { clipEmbedModelSelected, selectCLIPEmbedModel } from 'features/controlLayers/store/paramsSlice';
import { zModelIdentifierField } from 'features/nodes/types/common';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useCLIPEmbedModels } from 'services/api/hooks/modelsByType';
import type { CLIPEmbedModelConfig } from 'services/api/types';
import { useModelCombobox } from '../../../../common/hooks/useModelCombobox';
const ParamCLIPEmbedModelSelect = () => {
const dispatch = useAppDispatch();

View File

@@ -1,12 +1,12 @@
import { Combobox, FormControl, FormLabel } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { useModelCombobox } from 'common/hooks/useModelCombobox';
import { selectT5EncoderModel, t5EncoderModelSelected } from 'features/controlLayers/store/paramsSlice';
import { zModelIdentifierField } from 'features/nodes/types/common';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useT5EncoderModels } from 'services/api/hooks/modelsByType';
import type { T5EncoderBnbQuantizedLlmInt8bModelConfig, T5EncoderModelConfig } from 'services/api/types';
import { useModelCombobox } from '../../../../common/hooks/useModelCombobox';
const ParamT5EncoderModelSelect = () => {
const dispatch = useAppDispatch();

View File

@@ -59,8 +59,6 @@ export const isParameterCFGScale = (val: unknown): val is ParameterCFGScale =>
// #region Guidance parameter
const zParameterGuidance = z.number().min(1);
export type ParameterGuidance = z.infer<typeof zParameterGuidance>;
export const isParameterGuidance = (val: unknown): val is ParameterGuidance =>
zParameterGuidance.safeParse(val).success;
// #endregion
// #region CFG Rescale Multiplier
@@ -114,12 +112,12 @@ export type ParameterVAEModel = z.infer<typeof zParameterVAEModel>;
// #endregion
// #region T5Encoder Model
export const zParameterT5EncoderModel = zModelIdentifierField;
const zParameterT5EncoderModel = zModelIdentifierField;
export type ParameterT5EncoderModel = z.infer<typeof zParameterT5EncoderModel>;
// #endregion
// #region CLIP embed Model
export const zParameterCLIPEmbedModel = zModelIdentifierField;
const zParameterCLIPEmbedModel = zModelIdentifierField;
export type ParameterCLIPEmbedModel = z.infer<typeof zParameterCLIPEmbedModel>;
// #endregion

View File

@@ -5,22 +5,22 @@ import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
import { useAppSelector } from 'app/store/storeHooks';
import { selectIsFLUX, selectParamsSlice, selectVAEKey } from 'features/controlLayers/store/paramsSlice';
import ParamCFGRescaleMultiplier from 'features/parameters/components/Advanced/ParamCFGRescaleMultiplier';
import ParamCLIPEmbedModelSelect from 'features/parameters/components/Advanced/ParamCLIPEmbedModelSelect';
import ParamClipSkip from 'features/parameters/components/Advanced/ParamClipSkip';
import ParamT5EncoderModelSelect from 'features/parameters/components/Advanced/ParamT5EncoderModelSelect';
import ParamSeamlessXAxis from 'features/parameters/components/Seamless/ParamSeamlessXAxis';
import ParamSeamlessYAxis from 'features/parameters/components/Seamless/ParamSeamlessYAxis';
import { ParamSeedNumberInput } from 'features/parameters/components/Seed/ParamSeedNumberInput';
import { ParamSeedRandomize } from 'features/parameters/components/Seed/ParamSeedRandomize';
import { ParamSeedShuffle } from 'features/parameters/components/Seed/ParamSeedShuffle';
import ParamVAEModelSelect from 'features/parameters/components/VAEModel/ParamVAEModelSelect';
import ParamFLUXVAEModelSelect from 'features/parameters/components/VAEModel/ParamFLUXVAEModelSelect';
import ParamVAEModelSelect from 'features/parameters/components/VAEModel/ParamVAEModelSelect';
import ParamVAEPrecision from 'features/parameters/components/VAEModel/ParamVAEPrecision';
import { useStandaloneAccordionToggle } from 'features/settingsAccordions/hooks/useStandaloneAccordionToggle';
import { selectActiveTab } from 'features/ui/store/uiSelectors';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useGetModelConfigQuery } from 'services/api/endpoints/models';
import ParamT5EncoderModelSelect from '../../../parameters/components/Advanced/ParamT5EncoderModelSelect';
import ParamCLIPEmbedModelSelect from '../../../parameters/components/Advanced/ParamCLIPEmbedModelSelect';
const formLabelProps: FormLabelProps = {
minW: '9.2rem',

View File

@@ -4,9 +4,11 @@ import { EMPTY_ARRAY } from 'app/store/constants';
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
import { useAppSelector } from 'app/store/storeHooks';
import { selectLoRAsSlice } from 'features/controlLayers/store/lorasSlice';
import { selectIsFLUX } from 'features/controlLayers/store/paramsSlice';
import { LoRAList } from 'features/lora/components/LoRAList';
import LoRASelect from 'features/lora/components/LoRASelect';
import ParamCFGScale from 'features/parameters/components/Core/ParamCFGScale';
import ParamGuidance from 'features/parameters/components/Core/ParamGuidance';
import ParamScheduler from 'features/parameters/components/Core/ParamScheduler';
import ParamSteps from 'features/parameters/components/Core/ParamSteps';
import { NavigateToModelManagerButton } from 'features/parameters/components/MainModel/NavigateToModelManagerButton';
@@ -18,8 +20,6 @@ import { selectActiveTab } from 'features/ui/store/uiSelectors';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelectedModelConfig } from 'services/api/hooks/useSelectedModelConfig';
import ParamGuidance from '../../../parameters/components/Core/ParamGuidance';
import { selectIsFLUX } from '../../../controlLayers/store/paramsSlice';
const formLabelProps: FormLabelProps = {
minW: '4rem',

View File

@@ -176,8 +176,8 @@ const initialConfigState: AppConfig = {
numberInputMax: 6,
fineStep: 0.1,
coarseStep: 1,
}
}
},
},
};
export const configSlice = createSlice({

View File

@@ -17,7 +17,6 @@ import {
isIPAdapterModelConfig,
isLoRAModelConfig,
isNonRefinerMainModelConfig,
isNonRefinerNonFluxMainModelConfig,
isNonSDXLMainModelConfig,
isRefinerMainModelModelConfig,
isSDXLMainModelModelConfig,
@@ -43,7 +42,6 @@ const buildModelsHook =
return [modelConfigs, result] as const;
};
export const useSDMainModels = buildModelsHook(isNonRefinerNonFluxMainModelConfig);
export const useMainModels = buildModelsHook(isNonRefinerMainModelConfig);
export const useNonSDXLMainModels = buildModelsHook(isNonSDXLMainModelConfig);
export const useRefinerModels = buildModelsHook(isRefinerMainModelModelConfig);

View File

@@ -129,10 +129,6 @@ export const isNonRefinerMainModelConfig = (config: AnyModelConfig): config is M
return config.type === 'main' && config.base !== 'sdxl-refiner';
};
export const isNonRefinerNonFluxMainModelConfig = (config: AnyModelConfig): config is MainModelConfig => {
return config.type === 'main' && config.base !== 'sdxl-refiner' && config.base !== 'flux';
};
export const isRefinerMainModelModelConfig = (config: AnyModelConfig): config is MainModelConfig => {
return config.type === 'main' && config.base === 'sdxl-refiner';
};