Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fallback color and images #135

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions client/src/Annotation/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -183,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) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/SetupPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Loading