Skip to content

Commit b248b6d

Browse files
authored
fix: Merge pull request #240 from UniversalDataTool/update-ria
Support arbitrary split segments, update react-image-annotate
2 parents a90be62 + 6b8e87e commit b248b6d

File tree

4 files changed

+54
-42
lines changed

4 files changed

+54
-42
lines changed

cypress/integration/image-segmentation.spec.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ describe("Create a new", () => {
3838
cy.get("body").click().type("b")
3939
})
4040

41-
// TODO: change coordinates with cat coordinates
4241
it("should be able to draw a label box on canvas", () => {
4342
cy.get("canvas")
4443
.eq(0)
45-
.trigger("mousedown", { button: 0, screenX: 0, screenY: 210 })
46-
.trigger("mousemove", { button: 0, screenX: 0, screenY: 350 })
47-
.trigger("mousemove", { button: 0, screenX: 100, screenY: 350 })
48-
.trigger("mouseup", { force: true })
44+
.trigger("mousedown", { button: 0, clientX: 0, clientY: 50 })
45+
.trigger("mousemove", { button: 0, clientX: 0, clientY: 50 })
46+
.trigger("mousemove", { button: 0, clientX: 50, clientY: 50 })
47+
.trigger("mouseup", { button: 0 })
4948
cy.wait(50)
5049
})
5150

5251
it("should be able to label that box as a cat", () => {
53-
cy.contains("#1").click()
52+
cy.wait(200)
5453
cy.contains("Classification").click().type("cat{enter}")
5554
cy.wait(100)
5655
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"react-hotkeys": "^2.0.0",
107107
"react-i18next": "^11.4.0",
108108
"react-icons": "^3.9.0",
109-
"react-image-annotate": "^1.3.1",
109+
"react-image-annotate": "^1.5.0",
110110
"react-material-workspace-layout": "^0.1.6",
111111
"react-scripts": "^3.4.1",
112112
"react-select": "^3.0.8",

src/components/TransformImageSamplesIntoSegmentsDialog/index.js

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,19 @@ import SimpleDialog from "../SimpleDialog"
55
import { styled } from "@material-ui/core/styles"
66
import { setIn } from "seamless-immutable"
77
import Box from "@material-ui/core/Box"
8-
import Select from "react-select"
98
import range from "lodash/range"
9+
import TextField from "@material-ui/core/TextField"
1010

1111
const ErrorBox = styled("pre")({
1212
color: "red",
1313
whiteSpace: "prewrap",
1414
fontSize: 11,
1515
})
1616

17-
const splitOptions = [
18-
{ label: "2x2", value: "2x2" },
19-
{ label: "3x3", value: "3x3" },
20-
{ label: "1x2 (columns)", value: "1x2" },
21-
{ label: "1x3 (columns)", value: "1x3" },
22-
{ label: "2x3 (2 rows)", value: "2x3" },
23-
{ label: "4x4", value: "4x4" },
24-
{ label: "3x4 (3 rows)", value: "3x4" },
25-
]
26-
2717
export default ({ open, onChangeDataset, onClose, dataset }) => {
2818
const [errors, setErrors] = useState("")
29-
const [splitType, setSplitType] = useState(splitOptions[0].value)
19+
const [rows, setRows] = useState("2")
20+
const [columns, setColumns] = useState("2")
3021
return (
3122
<SimpleDialog
3223
open={open}
@@ -36,21 +27,21 @@ export default ({ open, onChangeDataset, onClose, dataset }) => {
3627
{
3728
text: "Convert Image Samples into Segments",
3829
onClick: async () => {
39-
const [rows, cols] = splitType.split("x").map((v) => parseInt(v))
30+
const [nRows, nCols] = [parseInt(rows), parseInt(columns)]
4031

4132
try {
4233
onChangeDataset(
4334
setIn(
4435
dataset,
4536
["samples"],
46-
range(rows).flatMap((y) =>
47-
range(cols).flatMap((x) =>
37+
range(nRows).flatMap((y) =>
38+
range(nCols).flatMap((x) =>
4839
dataset.samples.map((s) => {
4940
return setIn(s, ["allowedArea"], {
50-
x: x / cols,
51-
y: y / rows,
52-
width: 1 / cols,
53-
height: 1 / rows,
41+
x: x / nCols,
42+
y: y / nRows,
43+
width: 1 / nCols,
44+
height: 1 / nRows,
5445
})
5546
})
5647
)
@@ -71,10 +62,15 @@ export default ({ open, onChangeDataset, onClose, dataset }) => {
7162
which limits the labeling to a section of the image. This is useful when
7263
trying to reduce the amount of work per image sample.
7364
<Box padding={4}>
74-
<Select
75-
defaultValue={splitOptions[0]}
76-
options={splitOptions}
77-
onChange={({ value }) => setSplitType(value)}
65+
<TextField
66+
label="Rows"
67+
value={rows}
68+
onChange={(e) => setRows(e.target.value)}
69+
/>
70+
<TextField
71+
label="Columns"
72+
value={columns}
73+
onChange={(e) => setColumns(e.target.value)}
7874
/>
7975
</Box>
8076
{errors && <ErrorBox>{errors}</ErrorBox>}

yarn.lock

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9482,7 +9482,7 @@ fs.realpath@^1.0.0:
94829482
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
94839483
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
94849484

9485-
fscreen@^1.0.1:
9485+
fscreen@^1.0.2:
94869486
version "1.0.2"
94879487
resolved "https://registry.yarnpkg.com/fscreen/-/fscreen-1.0.2.tgz#c4c51d96d819d75a19d728e0df445f9be9bb984f"
94889488
integrity sha1-xMUdltgZ11oZ1yjg30Rfm+m7mE8=
@@ -16100,13 +16100,12 @@ react-focus-lock@^2.1.0:
1610016100
use-callback-ref "^1.2.1"
1610116101
use-sidecar "^1.0.1"
1610216102

16103-
react-full-screen@^0.2.4:
16104-
version "0.2.5"
16105-
resolved "https://registry.yarnpkg.com/react-full-screen/-/react-full-screen-0.2.5.tgz#bc79a5cdb9640d8b9b09e11a17fa54f6e6fa5789"
16106-
integrity sha512-LNkxjLWmiR+AwemSVdn/miUcBy8tHA6mDVS1qz1AM/DHNEtQbzkh5ok9A6g99502OqutQq1zBvCBGLV8rsB2tw==
16103+
react-full-screen@^0.3.1:
16104+
version "0.3.1"
16105+
resolved "https://registry.yarnpkg.com/react-full-screen/-/react-full-screen-0.3.1.tgz#60bf7b1ab140348bcfee4f5c98e927b6a0766809"
16106+
integrity sha512-lguQkP+vqwyZGHsLXvM90d8Aktp4gTlPUzszYKuQ9YvxNXIXtu+BILdwr/T+j6P2jREvEppgV20UEauv/0WLDg==
1610716107
dependencies:
16108-
"@types/react" "*"
16109-
fscreen "^1.0.1"
16108+
fscreen "^1.0.2"
1611016109

1611116110
react-github-btn@^1.2.0:
1611216111
version "1.2.0"
@@ -16148,10 +16147,10 @@ react-icons@^3.9.0:
1614816147
dependencies:
1614916148
camelcase "^5.0.0"
1615016149

16151-
react-image-annotate@^1.3.1:
16152-
version "1.3.1"
16153-
resolved "https://registry.yarnpkg.com/react-image-annotate/-/react-image-annotate-1.3.1.tgz#721353966c7a25a7c7d832262a50f9488ab78808"
16154-
integrity sha512-d3sErEQPmSIjq1ib89PEnIJa6T7eTgpen/fVHBFEJ9e5QyFAF6LQpnAS6s8jZ/wXtBLYTwstavYe2yNmY8kyPw==
16150+
react-image-annotate@^1.5.0:
16151+
version "1.5.0"
16152+
resolved "https://registry.yarnpkg.com/react-image-annotate/-/react-image-annotate-1.5.0.tgz#8e5dc18bcbe9b0c1e3ef239754d9e67f5cba4649"
16153+
integrity sha512-m1GP0N1fG7LMpRnBvLWtMaAACfwzJ95WldSYTSMDIbSnrFyYI3D0dq1T3r2jZ7CagQizzsBlQzO5FI4w+xdG8A==
1615516154
dependencies:
1615616155
"@fortawesome/fontawesome-svg-core" "^1.2.12"
1615716156
"@fortawesome/free-solid-svg-icons" "^5.6.3"
@@ -16165,10 +16164,11 @@ react-image-annotate@^1.3.1:
1616516164
material-survey "^1.0.34"
1616616165
mmgc1-cpp "^1.0.50"
1616716166
moment "^2.23.0"
16168-
react-full-screen "^0.2.4"
16167+
react-full-screen "^0.3.1"
1616916168
react-hotkeys "^2.0.0"
1617016169
react-json-view "^1.19.1"
1617116170
react-markdown "^4.0.6"
16171+
react-material-workspace-layout "^0.1.17"
1617216172
react-monaco-editor "^0.25.1"
1617316173
react-remove-scroll "^2.0.4"
1617416174
react-select "^3.0.8"
@@ -16232,6 +16232,18 @@ react-markdown@^4.0.6, react-markdown@^4.1.0:
1623216232
unist-util-visit "^1.3.0"
1623316233
xtend "^4.0.1"
1623416234

16235+
react-material-workspace-layout@^0.1.17:
16236+
version "0.1.17"
16237+
resolved "https://registry.yarnpkg.com/react-material-workspace-layout/-/react-material-workspace-layout-0.1.17.tgz#98a997e7d8671444fafe53caa4298b6643d1b9cb"
16238+
integrity sha512-GY+jFZ14IYKyzIW/KI8/R0Mttb5dTRdYDKdj++YAU/Z3HSQ7kZJ678mv5Nl7X0o081IpMFg5CRiBvvdozUmBtQ==
16239+
dependencies:
16240+
"@material-ui/core" "^4.10.0"
16241+
"@material-ui/icons" "^4.9.1"
16242+
classnames "^2.2.6"
16243+
react "^16.13.1"
16244+
react-use-dimensions "^1.2.1"
16245+
use-event-callback "^0.1.0"
16246+
1623516247
react-material-workspace-layout@^0.1.6:
1623616248
version "0.1.6"
1623716249
resolved "https://registry.yarnpkg.com/react-material-workspace-layout/-/react-material-workspace-layout-0.1.6.tgz#38412f8ca2e282ebc169d709cc12137351c8c427"
@@ -16444,6 +16456,11 @@ react-transition-group@^4.3.0, react-transition-group@^4.4.0:
1644416456
loose-envify "^1.4.0"
1644516457
prop-types "^15.6.2"
1644616458

16459+
react-use-dimensions@^1.2.1:
16460+
version "1.2.1"
16461+
resolved "https://registry.yarnpkg.com/react-use-dimensions/-/react-use-dimensions-1.2.1.tgz#eb1561db7b06c393209d2bffa449931dd93f7870"
16462+
integrity sha512-XL+Rup9Hosxx3Ap9xpyQMbVwuUa4BSqiOjfBb2zDuGs4uv2FesFV+m8Z/huRx2BNptMd9ARPqFuSNA62zhCozg==
16463+
1644716464
react-use-measure@^2.0.0:
1644816465
version "2.0.1"
1644916466
resolved "https://registry.yarnpkg.com/react-use-measure/-/react-use-measure-2.0.1.tgz#4f23f94c832cd4512da55acb300d1915dcbf3ae8"

0 commit comments

Comments
 (0)