tidy(ui): "imageName" -> "name"

This commit is contained in:
psychedelicious 2024-05-07 11:16:06 +10:00 committed by Kent Keirsey
parent 4adc592657
commit a7aa529b99
9 changed files with 47 additions and 47 deletions

View File

@ -73,25 +73,25 @@ const deleteControlAdapterImages = (state: RootState, dispatch: AppDispatch, ima
const deleteControlLayerImages = (state: RootState, dispatch: AppDispatch, imageDTO: ImageDTO) => { const deleteControlLayerImages = (state: RootState, dispatch: AppDispatch, imageDTO: ImageDTO) => {
state.controlLayers.present.layers.forEach((l) => { state.controlLayers.present.layers.forEach((l) => {
if (isRegionalGuidanceLayer(l)) { if (isRegionalGuidanceLayer(l)) {
if (l.ipAdapters.some((ipa) => ipa.image?.imageName === imageDTO.image_name)) { if (l.ipAdapters.some((ipa) => ipa.image?.name === imageDTO.image_name)) {
dispatch(layerDeleted(l.id)); dispatch(layerDeleted(l.id));
} }
} }
if (isControlAdapterLayer(l)) { if (isControlAdapterLayer(l)) {
if ( if (
l.controlAdapter.image?.imageName === imageDTO.image_name || l.controlAdapter.image?.name === imageDTO.image_name ||
l.controlAdapter.processedImage?.imageName === imageDTO.image_name l.controlAdapter.processedImage?.name === imageDTO.image_name
) { ) {
dispatch(layerDeleted(l.id)); dispatch(layerDeleted(l.id));
} }
} }
if (isIPAdapterLayer(l)) { if (isIPAdapterLayer(l)) {
if (l.ipAdapter.image?.imageName === imageDTO.image_name) { if (l.ipAdapter.image?.name === imageDTO.image_name) {
dispatch(layerDeleted(l.id)); dispatch(layerDeleted(l.id));
} }
} }
if (isInitialImageLayer(l)) { if (isInitialImageLayer(l)) {
if (l.image?.imageName === imageDTO.image_name) { if (l.image?.name === imageDTO.image_name) {
dispatch(layerDeleted(l.id)); dispatch(layerDeleted(l.id));
} }
} }

View File

@ -42,10 +42,10 @@ export const ControlAdapterImagePreview = memo(
const [isMouseOverImage, setIsMouseOverImage] = useState(false); const [isMouseOverImage, setIsMouseOverImage] = useState(false);
const { currentData: controlImage, isError: isErrorControlImage } = useGetImageDTOQuery( const { currentData: controlImage, isError: isErrorControlImage } = useGetImageDTOQuery(
controlAdapter.image?.imageName ?? skipToken controlAdapter.image?.name ?? skipToken
); );
const { currentData: processedControlImage, isError: isErrorProcessedControlImage } = useGetImageDTOQuery( const { currentData: processedControlImage, isError: isErrorProcessedControlImage } = useGetImageDTOQuery(
controlAdapter.processedImage?.imageName ?? skipToken controlAdapter.processedImage?.name ?? skipToken
); );
const [changeIsIntermediate] = useChangeImageIsIntermediateMutation(); const [changeIsIntermediate] = useChangeImageIsIntermediateMutation();

View File

@ -35,7 +35,7 @@ export const IPAdapterImagePreview = memo(
const shift = useShiftModifier(); const shift = useShiftModifier();
const { currentData: controlImage, isError: isErrorControlImage } = useGetImageDTOQuery( const { currentData: controlImage, isError: isErrorControlImage } = useGetImageDTOQuery(
image?.imageName ?? skipToken image?.name ?? skipToken
); );
const handleResetControlImage = useCallback(() => { const handleResetControlImage = useCallback(() => {
onChangeImage(null); onChangeImage(null);

View File

@ -32,7 +32,7 @@ export const InitialImagePreview = memo(({ image, onChangeImage, droppableData,
const optimalDimension = useAppSelector(selectOptimalDimension); const optimalDimension = useAppSelector(selectOptimalDimension);
const shift = useShiftModifier(); const shift = useShiftModifier();
const { currentData: imageDTO, isError: isErrorControlImage } = useGetImageDTOQuery(image?.imageName ?? skipToken); const { currentData: imageDTO, isError: isErrorControlImage } = useGetImageDTOQuery(image?.name ?? skipToken);
const onReset = useCallback(() => { const onReset = useCallback(() => {
onChangeImage(null); onChangeImage(null);

View File

@ -79,7 +79,7 @@ export type ProcessorConfig =
| ZoeDepthProcessorConfig; | ZoeDepthProcessorConfig;
export type ImageWithDims = { export type ImageWithDims = {
imageName: string; name: string;
width: number; width: number;
height: number; height: number;
}; };
@ -190,7 +190,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
type: 'canny_image_processor', type: 'canny_image_processor',
image: { image_name: image.imageName }, image: { image_name: image.name },
detect_resolution: minDim(image), detect_resolution: minDim(image),
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
@ -207,7 +207,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
type: 'color_map_image_processor', type: 'color_map_image_processor',
image: { image_name: image.imageName }, image: { image_name: image.name },
}), }),
}, },
content_shuffle_image_processor: { content_shuffle_image_processor: {
@ -223,7 +223,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
detect_resolution: minDim(image), detect_resolution: minDim(image),
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
@ -239,7 +239,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
resolution: minDim(image), resolution: minDim(image),
}), }),
}, },
@ -254,7 +254,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
detect_resolution: minDim(image), detect_resolution: minDim(image),
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
@ -269,7 +269,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
detect_resolution: minDim(image), detect_resolution: minDim(image),
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
@ -285,7 +285,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
detect_resolution: minDim(image), detect_resolution: minDim(image),
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
@ -302,7 +302,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
detect_resolution: minDim(image), detect_resolution: minDim(image),
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
@ -319,7 +319,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
detect_resolution: minDim(image), detect_resolution: minDim(image),
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
@ -336,7 +336,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
detect_resolution: minDim(image), detect_resolution: minDim(image),
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
@ -351,7 +351,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
detect_resolution: minDim(image), detect_resolution: minDim(image),
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
@ -369,7 +369,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
}, },
@ -385,7 +385,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
detect_resolution: minDim(image), detect_resolution: minDim(image),
image_resolution: minDim(image), image_resolution: minDim(image),
}), }),
@ -400,7 +400,7 @@ export const CA_PROCESSOR_DATA: CAProcessorsData = {
}), }),
buildNode: (image, config) => ({ buildNode: (image, config) => ({
...config, ...config,
image: { image_name: image.imageName }, image: { image_name: image.name },
}), }),
}, },
}; };
@ -462,7 +462,7 @@ export const buildControlAdapterProcessorV2 = (
}; };
export const imageDTOToImageWithDims = ({ image_name, width, height }: ImageDTO): ImageWithDims => ({ export const imageDTOToImageWithDims = ({ image_name, width, height }: ImageDTO): ImageWithDims => ({
imageName: image_name, name: image_name,
width, width,
height, height,
}); });

View File

@ -510,7 +510,7 @@ const updateInitialImageLayerImageSource = async (
reduxLayer: InitialImageLayer reduxLayer: InitialImageLayer
) => { ) => {
if (reduxLayer.image) { if (reduxLayer.image) {
const { imageName } = reduxLayer.image; const imageName = reduxLayer.image.name;
const req = getStore().dispatch(imagesApi.endpoints.getImageDTO.initiate(imageName)); const req = getStore().dispatch(imagesApi.endpoints.getImageDTO.initiate(imageName));
const imageDTO = await req.unwrap(); const imageDTO = await req.unwrap();
req.unsubscribe(); req.unsubscribe();
@ -543,7 +543,7 @@ const renderInitialImageLayer = (stage: Konva.Stage, reduxLayer: InitialImageLay
let imageSourceNeedsUpdate = false; let imageSourceNeedsUpdate = false;
if (canvasImageSource instanceof HTMLImageElement) { if (canvasImageSource instanceof HTMLImageElement) {
const image = reduxLayer.image; const image = reduxLayer.image;
if (image && canvasImageSource.id !== getCALayerImageId(reduxLayer.id, image.imageName)) { if (image && canvasImageSource.id !== getCALayerImageId(reduxLayer.id, image.name)) {
imageSourceNeedsUpdate = true; imageSourceNeedsUpdate = true;
} else if (!image) { } else if (!image) {
imageSourceNeedsUpdate = true; imageSourceNeedsUpdate = true;
@ -585,7 +585,7 @@ const updateControlNetLayerImageSource = async (
) => { ) => {
const image = reduxLayer.controlAdapter.processedImage ?? reduxLayer.controlAdapter.image; const image = reduxLayer.controlAdapter.processedImage ?? reduxLayer.controlAdapter.image;
if (image) { if (image) {
const { imageName } = image; const imageName = image.name;
const req = getStore().dispatch(imagesApi.endpoints.getImageDTO.initiate(imageName)); const req = getStore().dispatch(imagesApi.endpoints.getImageDTO.initiate(imageName));
const imageDTO = await req.unwrap(); const imageDTO = await req.unwrap();
req.unsubscribe(); req.unsubscribe();
@ -653,7 +653,7 @@ const renderControlNetLayer = (stage: Konva.Stage, reduxLayer: ControlAdapterLay
let imageSourceNeedsUpdate = false; let imageSourceNeedsUpdate = false;
if (canvasImageSource instanceof HTMLImageElement) { if (canvasImageSource instanceof HTMLImageElement) {
const image = reduxLayer.controlAdapter.processedImage ?? reduxLayer.controlAdapter.image; const image = reduxLayer.controlAdapter.processedImage ?? reduxLayer.controlAdapter.image;
if (image && canvasImageSource.id !== getCALayerImageId(reduxLayer.id, image.imageName)) { if (image && canvasImageSource.id !== getCALayerImageId(reduxLayer.id, image.name)) {
imageSourceNeedsUpdate = true; imageSourceNeedsUpdate = true;
} else if (!image) { } else if (!image) {
imageSourceNeedsUpdate = true; imageSourceNeedsUpdate = true;

View File

@ -46,18 +46,18 @@ export const getImageUsage = (
const isControlLayerImage = controlLayers.layers.some((l) => { const isControlLayerImage = controlLayers.layers.some((l) => {
if (isRegionalGuidanceLayer(l)) { if (isRegionalGuidanceLayer(l)) {
return l.ipAdapters.some((ipa) => ipa.image?.imageName === image_name); return l.ipAdapters.some((ipa) => ipa.image?.name === image_name);
} }
if (isControlAdapterLayer(l)) { if (isControlAdapterLayer(l)) {
return ( return (
l.controlAdapter.image?.imageName === image_name || l.controlAdapter.processedImage?.imageName === image_name l.controlAdapter.image?.name === image_name || l.controlAdapter.processedImage?.name === image_name
); );
} }
if (isIPAdapterLayer(l)) { if (isIPAdapterLayer(l)) {
return l.ipAdapter.image?.imageName === image_name; return l.ipAdapter.image?.name === image_name;
} }
if (isInitialImageLayer(l)) { if (isInitialImageLayer(l)) {
return l.image?.imageName === image_name; return l.image?.name === image_name;
} }
return false; return false;
}); });

View File

@ -56,12 +56,12 @@ const buildControlImage = (
if (processedImage && processorConfig) { if (processedImage && processorConfig) {
// We've processed the image in the app - use it for the control image. // We've processed the image in the app - use it for the control image.
return { return {
image_name: processedImage.imageName, image_name: processedImage.name,
}; };
} else if (image) { } else if (image) {
// No processor selected, and we have an image - the user provided a processed image, use it for the control image. // No processor selected, and we have an image - the user provided a processed image, use it for the control image.
return { return {
image_name: image.imageName, image_name: image.name,
}; };
} }
assert(false, 'Attempted to add unprocessed control image'); assert(false, 'Attempted to add unprocessed control image');
@ -76,7 +76,7 @@ const buildControlNetMetadata = (controlNet: ControlNetConfigV2): S['ControlNetM
const processed_image = const processed_image =
processedImage && processorConfig processedImage && processorConfig
? { ? {
image_name: processedImage.imageName, image_name: processedImage.name,
} }
: null; : null;
@ -88,7 +88,7 @@ const buildControlNetMetadata = (controlNet: ControlNetConfigV2): S['ControlNetM
end_step_percent: beginEndStepPct[1], end_step_percent: beginEndStepPct[1],
resize_mode: 'just_resize', resize_mode: 'just_resize',
image: { image: {
image_name: image.imageName, image_name: image.name,
}, },
processed_image, processed_image,
}; };
@ -169,7 +169,7 @@ const buildT2IAdapterMetadata = (t2iAdapter: T2IAdapterConfigV2): S['T2IAdapterM
const processed_image = const processed_image =
processedImage && processorConfig processedImage && processorConfig
? { ? {
image_name: processedImage.imageName, image_name: processedImage.name,
} }
: null; : null;
@ -180,7 +180,7 @@ const buildT2IAdapterMetadata = (t2iAdapter: T2IAdapterConfigV2): S['T2IAdapterM
end_step_percent: beginEndStepPct[1], end_step_percent: beginEndStepPct[1],
resize_mode: 'just_resize', resize_mode: 'just_resize',
image: { image: {
image_name: image.imageName, image_name: image.name,
}, },
processed_image, processed_image,
}; };
@ -266,7 +266,7 @@ const buildIPAdapterMetadata = (ipAdapter: IPAdapterConfigV2): S['IPAdapterMetad
begin_step_percent: beginEndStepPct[0], begin_step_percent: beginEndStepPct[0],
end_step_percent: beginEndStepPct[1], end_step_percent: beginEndStepPct[1],
image: { image: {
image_name: image.imageName, image_name: image.name,
}, },
}; };
}; };
@ -319,7 +319,7 @@ const addGlobalIPAdaptersToGraph = async (
begin_step_percent: beginEndStepPct[0], begin_step_percent: beginEndStepPct[0],
end_step_percent: beginEndStepPct[1], end_step_percent: beginEndStepPct[1],
image: { image: {
image_name: image.imageName, image_name: image.name,
}, },
}; };
@ -402,7 +402,7 @@ export const addControlLayersToGraph = async (state: RootState, graph: NonNullab
// Only layers with prompts get added to the graph // Only layers with prompts get added to the graph
.filter((l) => { .filter((l) => {
const hasTextPrompt = Boolean(l.positivePrompt || l.negativePrompt); const hasTextPrompt = Boolean(l.positivePrompt || l.negativePrompt);
const hasIPAdapter = l.ipAdapters.length !== 0; const hasIPAdapter = l.ipAdapters.filter((ipa) => ipa.image).length > 0;
return hasTextPrompt || hasIPAdapter; return hasTextPrompt || hasIPAdapter;
}); });
@ -648,7 +648,7 @@ export const addControlLayersToGraph = async (state: RootState, graph: NonNullab
begin_step_percent: beginEndStepPct[0], begin_step_percent: beginEndStepPct[0],
end_step_percent: beginEndStepPct[1], end_step_percent: beginEndStepPct[1],
image: { image: {
image_name: image.imageName, image_name: image.name,
}, },
}; };
@ -673,7 +673,7 @@ export const addControlLayersToGraph = async (state: RootState, graph: NonNullab
const getMaskImage = async (layer: RegionalGuidanceLayer, blob: Blob): Promise<ImageDTO> => { const getMaskImage = async (layer: RegionalGuidanceLayer, blob: Blob): Promise<ImageDTO> => {
if (layer.uploadedMaskImage) { if (layer.uploadedMaskImage) {
const imageDTO = await getImageDTO(layer.uploadedMaskImage.imageName); const imageDTO = await getImageDTO(layer.uploadedMaskImage.name);
if (imageDTO) { if (imageDTO) {
return imageDTO; return imageDTO;
} }

View File

@ -66,7 +66,7 @@ export const addInitialImageToLinearGraph = (
id: RESIZE, id: RESIZE,
type: 'img_resize', type: 'img_resize',
image: { image: {
image_name: initialImage.imageName, image_name: initialImage.name,
}, },
is_intermediate: true, is_intermediate: true,
width, width,
@ -103,7 +103,7 @@ export const addInitialImageToLinearGraph = (
} else { } else {
// We are not resizing, so we need to set the image on the `IMAGE_TO_LATENTS` node explicitly // We are not resizing, so we need to set the image on the `IMAGE_TO_LATENTS` node explicitly
i2lNode.image = { i2lNode.image = {
image_name: initialImage.imageName, image_name: initialImage.name,
}; };
// Pass the image's dimensions to the `NOISE` node // Pass the image's dimensions to the `NOISE` node
@ -126,7 +126,7 @@ export const addInitialImageToLinearGraph = (
upsertMetadata(graph, { upsertMetadata(graph, {
generation_mode: isSDXL ? 'sdxl_img2img' : 'img2img', generation_mode: isSDXL ? 'sdxl_img2img' : 'img2img',
strength: denoisingStrength, strength: denoisingStrength,
init_image: initialImage.imageName, init_image: initialImage.name,
}); });
return true; return true;