From 95f68dcac7174bcd21f30eb07add8c8a0af09935 Mon Sep 17 00:00:00 2001 From: Anett Date: Sat, 6 Apr 2024 12:34:39 +0200 Subject: [PATCH 1/3] added translation to category --- README.md | 6 +++--- src/Annotator/index.jsx | 5 ++++- src/ClassSelectionMenu/index.jsx | 4 ++-- src/DemoSite/Examples.jsx | 6 +++--- src/DemoSite/simple-segmentation-example.json | 4 ++-- src/ImageCanvas/index.jsx | 5 ++++- src/MainLayout/index.jsx | 6 ------ 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 08e7f68f..1eeed0a0 100755 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ import ReactImageAnnotate from "react-image-annotate"; const App = () => ( ` | Allowed "tags" (mutually inclusive classifications) for regions. | | -| `regionClsList` | `Array` | Allowed "classes" (mutually exclusive classifications) for regions. +| `regionClsList` | `Array{name: , translation: ` | Allowed "classes" (mutually exclusive classifications) for regions. | `regionColorList` | `Array` | Custom color list for regions. Default colors are used if not specified. -| `preselectCls` | `string` | Put in the class that should be preselected when creating a new Box/Polygon etc. | | +| `preselectCls` | `string` | Put in the class that should be preselected when creating a new Box/Polygon etc. | | | `imageTagList` | `Array` | Allowed tags for entire image. | | | `imageClsList` | `Array` | Allowed classes for entire image. | | | `enabledTools` | `Array` | Tools allowed to be used. e.g. "select", "create-point", "create-box", "create-polygon" | Everything. | diff --git a/src/Annotator/index.jsx b/src/Annotator/index.jsx index 502b7c8a..0eecebd7 100644 --- a/src/Annotator/index.jsx +++ b/src/Annotator/index.jsx @@ -174,7 +174,10 @@ Annotator.propTypes = { enabledTools: PropTypes.arrayOf(PropTypes.string), selectedTool: PropTypes.string, regionTagList: PropTypes.arrayOf(PropTypes.string), - regionClsList: PropTypes.arrayOf(PropTypes.string), + regionClsList: PropTypes.arrayOf(PropTypes.shape({ + name: PropTypes.string.isRequired, + translation: PropTypes.string, +})), regionColorList: PropTypes.arrayOf(PropTypes.string), preselectCls: PropTypes.string, imageTagList: PropTypes.arrayOf(PropTypes.string), diff --git a/src/ClassSelectionMenu/index.jsx b/src/ClassSelectionMenu/index.jsx index 4c432331..109f64de 100644 --- a/src/ClassSelectionMenu/index.jsx +++ b/src/ClassSelectionMenu/index.jsx @@ -83,7 +83,7 @@ export const ClassSelectionMenu = ({ > {regionClsList.map((label, index) => ( onSelectCls(label)} > @@ -91,7 +91,7 @@ export const ClassSelectionMenu = ({ style={{backgroundColor: index < regionColorList.length ? regionColorList[index] : colors[index % colors.length]}} /> diff --git a/src/DemoSite/Examples.jsx b/src/DemoSite/Examples.jsx index 3f8716c5..242e4414 100644 --- a/src/DemoSite/Examples.jsx +++ b/src/DemoSite/Examples.jsx @@ -33,7 +33,7 @@ export const examples = { // regionTagList: [], // regionClsList: ["hotdog"], regionTagList: ["has-bun"], - regionClsList: ["hotdog", "not-hotdog"], + regionClsList: [{name: "hotdog"}, {name: "not-hotdog"}], regionColorList: ["#4d0c89", "#55d68d"], preselectCls: "not-hotdog", enabledTools: ["create-point", "create-box", "create-polygon", "create-line", "create-expanding-line"], @@ -56,7 +56,7 @@ export const examples = { // regionTagList: [], // regionClsList: ["hotdog"], regionTagList: ["has-bun"], - regionClsList: ["Line-Crossing", "Area-Occupancy"], + regionClsList: [{name: "name.lightbarrier", translation: "Light Barrier"}, {name: "name.parkingarea", translation: "Parking Area"}], preselectCls: "not-hotdog", // showTags: true, images: [ @@ -71,7 +71,7 @@ export const examples = { "Simple Segmentation": () => ({ taskDescription: "Annotate each image according to this _markdown_ specification.", - regionClsList: ["car", "truck"], + regionClsList: [{name: "car"}, {name: "truck"}], enabledTools: ["select", "create-polygon"], images: [ { diff --git a/src/DemoSite/simple-segmentation-example.json b/src/DemoSite/simple-segmentation-example.json index 523ba23a..6c3dfef5 100644 --- a/src/DemoSite/simple-segmentation-example.json +++ b/src/DemoSite/simple-segmentation-example.json @@ -559,8 +559,8 @@ ], "labelImages": false, "regionClsList": [ - "car", - "truck" + { "name": "car"}, + { "name": "truck"} ], "regionTagList": [], "imageClsList": [], diff --git a/src/ImageCanvas/index.jsx b/src/ImageCanvas/index.jsx index a2f7c661..5ad3da93 100644 --- a/src/ImageCanvas/index.jsx +++ b/src/ImageCanvas/index.jsx @@ -415,7 +415,10 @@ ImageCanvas.propTypes = { showHighlightBox: PropTypes.bool, showPointDistances: PropTypes.bool, pointDistancePrecision: PropTypes.number, - regionClsList: PropTypes.arrayOf(PropTypes.string), + regionClsList: PropTypes.arrayOf(PropTypes.shape({ + name: PropTypes.string.isRequired, + translation: PropTypes.string, + })), regionTagList: PropTypes.arrayOf(PropTypes.string), allowedArea: PropTypes.shape({x: PropTypes.number, y: PropTypes.number, w: PropTypes.number, h: PropTypes.number}), RegionEditLabel: PropTypes.element, diff --git a/src/MainLayout/index.jsx b/src/MainLayout/index.jsx index f7d0db36..179e4756 100644 --- a/src/MainLayout/index.jsx +++ b/src/MainLayout/index.jsx @@ -276,12 +276,6 @@ export const MainLayout = ({ expandedByDefault /> ), - // (state.images?.length || 0) > 1 && ( - // - // ), Date: Mon, 8 Apr 2024 12:26:46 +0200 Subject: [PATCH 2/3] bugfix select tools --- src/Annotator/index.jsx | 5 ++++- src/Annotator/reducers/general-reducer.js | 4 ++-- src/DemoSite/Examples.jsx | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Annotator/index.jsx b/src/Annotator/index.jsx index 0eecebd7..18521cf9 100644 --- a/src/Annotator/index.jsx +++ b/src/Annotator/index.jsx @@ -179,7 +179,10 @@ Annotator.propTypes = { translation: PropTypes.string, })), regionColorList: PropTypes.arrayOf(PropTypes.string), - preselectCls: PropTypes.string, + preselectCls: PropTypes.shape({ + name: PropTypes.string.isRequired, + translation: PropTypes.string +}), imageTagList: PropTypes.arrayOf(PropTypes.string), imageClsList: PropTypes.arrayOf(PropTypes.string), keyframes: PropTypes.object, diff --git a/src/Annotator/reducers/general-reducer.js b/src/Annotator/reducers/general-reducer.js index f77509c2..3697eb9b 100644 --- a/src/Annotator/reducers/general-reducer.js +++ b/src/Annotator/reducers/general-reducer.js @@ -25,11 +25,11 @@ export default (state, action) => { action.y = clamp(action.y, aa.y, aa.y + aa.h) } - if (action.type === "ON_CLS_ADDED" && action.cls && action.cls !== "") { + if (action.type === "ON_CLS_ADDED" && action.cls && action.cls.name !== "") { const oldRegionClsList = state.regionClsList const newState = { ...state, - regionClsList: oldRegionClsList.concat(action.cls), + regionClsList: oldRegionClsList.concat(action.cls.name), } return newState } diff --git a/src/DemoSite/Examples.jsx b/src/DemoSite/Examples.jsx index 242e4414..63c45de7 100644 --- a/src/DemoSite/Examples.jsx +++ b/src/DemoSite/Examples.jsx @@ -4,11 +4,11 @@ import {setIn} from 'seamless-immutable'; const userReducer = (state, action) => { switch (action.type) { case "SELECT_CLASSIFICATION": { - switch (action.cls) { - case "Line-Crossing": { + switch (action.cls?.name) { + case "name.lightbarrier": { return setIn(state, ["selectedTool"], "create-line"); } - case "Area-Occupancy": { + case "name.parkingarea": { return setIn(state, ["selectedTool"], "create-polygon"); } } @@ -57,7 +57,7 @@ export const examples = { // regionClsList: ["hotdog"], regionTagList: ["has-bun"], regionClsList: [{name: "name.lightbarrier", translation: "Light Barrier"}, {name: "name.parkingarea", translation: "Parking Area"}], - preselectCls: "not-hotdog", + preselectCls: {name: "name.lightbarrier", translation: "Light Barrier"}, // showTags: true, images: [ { From 42d246dbdb4a16713a84e4b29871450271d7cf64 Mon Sep 17 00:00:00 2001 From: Anett Date: Mon, 8 Apr 2024 13:47:30 +0200 Subject: [PATCH 3/3] add classification --- src/Annotator/index.jsx | 5 ++++- src/RegionLabel/index.jsx | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Annotator/index.jsx b/src/Annotator/index.jsx index 18521cf9..6d8890c8 100644 --- a/src/Annotator/index.jsx +++ b/src/Annotator/index.jsx @@ -184,7 +184,10 @@ Annotator.propTypes = { translation: PropTypes.string }), imageTagList: PropTypes.arrayOf(PropTypes.string), - imageClsList: PropTypes.arrayOf(PropTypes.string), + imageClsList: PropTypes.shape({ + name: PropTypes.string.isRequired, + translation: PropTypes.string +}), keyframes: PropTypes.object, taskDescription: PropTypes.string, RegionEditLabel: PropTypes.node, diff --git a/src/RegionLabel/index.jsx b/src/RegionLabel/index.jsx index 6d1483bb..cf952f0e 100644 --- a/src/RegionLabel/index.jsx +++ b/src/RegionLabel/index.jsx @@ -123,10 +123,10 @@ export const RegionLabel = ({ }) }} value={ - region.cls ? {label: region.cls, value: region.cls} : null + region.cls ? {label: region.cls.translation, value: region.cls} : null } options={asMutable( - allowedClasses.map((c) => ({value: c, label: c})) + allowedClasses.map((c) => ({value: c, label: c.translation})) )} />