From cb8e4359b31f7fe534b5b9be453e974ee2c01335 Mon Sep 17 00:00:00 2001 From: sumn2u Date: Tue, 9 Jul 2024 13:40:00 -0500 Subject: [PATCH 1/2] support fallback color for updated regions --- client/src/Annotation/index.jsx | 7 +++++-- client/src/SetupPage/index.jsx | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/Annotation/index.jsx b/client/src/Annotation/index.jsx index 2733d43..c476d5a 100644 --- a/client/src/Annotation/index.jsx +++ b/client/src/Annotation/index.jsx @@ -149,9 +149,12 @@ export default () => { const mapRegionsColor = (regions) => { if(regions === undefined) return [] return regions.map((region, index) => { - const classLabels = settingsConfig.settings.configuration.labels; + const classLabels = settings.configuration.labels.length > 0 + ? settings.configuration.labels + : settingsConfig.settings.configuration.labels; + const clsIndex = classLabels.findIndex(label => label.id === region.cls); - const regionColor = clsIndex < classLabels.length ? colors[clsIndex]: colors[clsIndex % colors.length] + const regionColor = clsIndex !== -1 ? (clsIndex < classLabels.length ? colors[clsIndex]: colors[clsIndex % colors.length]) : colors[0] return { ...region, color: regionColor diff --git a/client/src/SetupPage/index.jsx b/client/src/SetupPage/index.jsx index f502ea0..36536ee 100644 --- a/client/src/SetupPage/index.jsx +++ b/client/src/SetupPage/index.jsx @@ -78,8 +78,8 @@ export const SetupPage = ({setConfiguration, settings, setShowLabel, showAnnotat } }; settingsConfig.changeSetting('settings',newSettings); - showAnnotationLab(newSettings) setConfiguration({type: "UPDATE_CONFIGURATION", payload: newConfig}) + showAnnotationLab(newSettings) } const {t} = useTranslation(); From 7afeaa20bc92d19e5de672212627ecb4601dbf9d Mon Sep 17 00:00:00 2001 From: sumn2u Date: Tue, 9 Jul 2024 13:45:56 -0500 Subject: [PATCH 2/2] ensure last save image is within image index bound --- client/src/Annotation/index.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/Annotation/index.jsx b/client/src/Annotation/index.jsx index c476d5a..5a22388 100644 --- a/client/src/Annotation/index.jsx +++ b/client/src/Annotation/index.jsx @@ -186,7 +186,11 @@ export default () => { images: imageMap, imagesBlob: images })); - changeSelectedImageIndex(lastOpenedImage) + + // Ensure lastOpenedImage index is within bounds + const validImageIndex = lastOpenedImage >= images.length ? 0 : lastOpenedImage; + + changeSelectedImageIndex(validImageIndex) setImageNames(imageMap); setIsLoading(false) } catch (error) {