Skip to content

Commit 04f1228

Browse files
committed
Fix Coco converter
1 parent 176461a commit 04f1228

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

superannotate/input_converters/converters/coco_converters/coco_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _maskfrRLE(rle):
3535
x = np.arange(len(rle['counts']), dtype=np.uint8) % 2
3636
bitmask = np.repeat(x, rle['counts'], axis=0)
3737

38-
return bitmask.reshape((rle['size'][1], rle['size'][0])).T
38+
return bitmask.reshape((rle['size'][1], rle['size'][0]))
3939

4040

4141
def _toString(rle_counts):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"instances": [{"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [561.59, 334.07, 557.88, 357.86, 555.65, 386.12, 554.16, 399.5, 552.67, 407.68, 551.93, 413.63, 548.21, 415.11, 543.01, 415.86, 538.54, 415.86, 535.57, 418.83, 531.85, 417.35, 530.37, 412.14, 529.62, 405.45, 527.39, 400.99, 525.9, 389.83, 526.65, 366.79, 527.39, 356.38, 519.96, 345.22, 518.47, 334.07, 521.44, 313.99, 523.67, 304.33, 532.6, 299.12, 537.8, 296.15, 539.29, 289.46, 544.49, 287.23, 553.41, 287.23, 557.13, 292.43, 557.88, 301.35, 561.59, 306.56, 565.31, 313.99, 569.03, 320.69, 572.75, 325.15, 572.0, 332.58, 566.8, 334.07], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [566.16, 311.99, 574.55, 303.6, 572.98, 296.52, 578.22, 292.06, 580.85, 292.84, 583.73, 297.04, 584.26, 302.55, 585.57, 307.27, 588.71, 310.42, 592.65, 313.3, 595.8, 320.12, 597.37, 326.68, 597.37, 334.55, 597.37, 342.68, 596.58, 348.19, 594.75, 351.07, 589.5, 353.96, 586.88, 354.74, 586.62, 373.37, 586.62, 384.91, 586.88, 389.37, 578.38, 391.08, 572.16, 391.53, 574.16, 385.31, 575.49, 381.75, 576.38, 375.09, 576.38, 364.43, 576.38, 358.66, 575.71, 358.88, 571.49, 370.43, 570.83, 378.2, 569.05, 387.31, 567.72, 390.41, 563.72, 391.75, 560.17, 391.53, 555.95, 390.19, 555.72, 387.75, 557.72, 377.31, 560.17, 370.2, 561.72, 364.43, 562.61, 359.32, 560.83, 352.44, 559.72, 348.88, 558.61, 346.66, 562.61, 335.08, 570.6, 329.98, 571.71, 325.76, 570.16, 321.98, 567.49, 319.09, 564.16, 316.87, 563.5, 314.65, 566.61, 310.88], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [500.35, 315.98, 499.42, 304.21, 494.16, 296.47, 491.37, 292.44, 486.1, 290.58, 482.7, 293.68, 483.93, 296.78, 486.1, 303.9, 485.48, 310.41, 482.08, 319.08, 482.08, 321.25, 483.93, 323.73, 487.03, 324.04, 488.27, 328.68, 500.97, 328.99, 501.9, 324.04, 496.64, 324.97, 490.75, 324.04, 491.06, 320.63, 497.25, 318.46, 497.25, 318.46], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [489.2, 331.78, 500.35, 331.47, 501.28, 342.31, 491.68, 340.46], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [501.67, 304.38, 499.78, 302.22, 498.97, 301.55, 498.3, 300.6, 498.03, 300.06, 498.84, 299.12, 498.97, 298.72, 497.62, 298.04, 496.27, 297.1, 496.0, 295.35, 495.73, 292.92, 496.0, 290.36, 497.76, 289.41, 499.64, 289.14, 500.59, 289.28, 501.26, 290.49, 501.26, 293.32, 501.94, 294.54, 503.96, 295.08, 504.09, 295.08, 506.12, 296.18, 503.43, 297.26, 503.02, 299.14, 503.43, 301.71, 503.29, 303.46, 502.75, 304.54, 501.94, 304.27, 501.81, 304.13], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [388.43, 347.51, 384.57, 315.93, 373.34, 320.14, 370.88, 314.87, 382.46, 306.45, 391.59, 293.12, 397.9, 293.12, 402.47, 303.64, 414.4, 316.28, 414.05, 321.89, 400.36, 315.58, 407.38, 353.83, 386.32, 349.97], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [379.89, 333.29, 380.62, 317.6, 372.89, 319.53, 374.1, 323.15, 369.51, 331.6, 372.41, 334.25, 376.76, 334.74, 378.2, 333.77, 379.89, 334.01], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [370.72, 314.94, 381.1, 307.46, 379.89, 299.02, 381.58, 295.4, 381.1, 291.53, 379.41, 290.81, 377.48, 292.5, 376.03, 294.43, 374.34, 295.15, 369.51, 295.64, 368.55, 300.95, 368.31, 306.26, 368.55, 309.64, 369.51, 311.81, 371.69, 313.5], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [337.25, 326.87, 334.29, 313.76, 334.08, 302.12, 336.19, 298.95, 336.4, 293.87, 338.73, 293.87, 341.06, 295.35, 341.27, 297.05, 340.84, 303.18, 342.54, 299.58, 345.71, 301.7, 345.5, 306.56, 342.96, 309.1, 342.96, 325.39, 342.54, 333.85, 344.23, 338.29, 337.25, 337.23, 335.77, 328.35], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [17.39, 311.25, 25.43, 296.98, 28.36, 292.22, 34.95, 289.3, 42.26, 292.59, 44.46, 294.78, 46.65, 306.49, 34.21, 324.41, 37.51, 328.44, 36.41, 335.02, 35.31, 338.32, 29.09, 334.29, 17.39, 311.98], "className": "snowboard"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [7.51, 328.44, 1.29, 338.68, 0.0, 342.71, 0.56, 385.51, 8.24, 369.05, 10.44, 376.73, 18.85, 370.14, 22.51, 363.19, 15.19, 356.61, 21.41, 342.71, 8.97, 330.63], "className": "snowboard"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [0.15, 278.36, 5.11, 283.32, 9.44, 295.4, 12.54, 298.8, 13.47, 300.04, 13.47, 302.52, 17.5, 311.81, 20.28, 318.63, 23.69, 326.06, 25.86, 331.02, 25.86, 333.19, 25.24, 336.9, 23.38, 337.52, 22.14, 332.26, 18.43, 331.33, 17.5, 331.33, 15.95, 322.96, 14.09, 318.63, 8.82, 309.34, 0.77, 296.64], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [0.38, 424.12, 3.2, 424.3, 5.64, 422.99, 7.34, 419.6, 10.53, 418.1, 7.9, 411.89, 5.64, 409.82, 6.02, 407.57, 6.21, 405.87, 5.08, 400.04, 4.14, 391.77, 4.14, 389.14, 7.53, 383.5, 8.47, 375.22, 9.78, 366.95, 8.09, 367.7, 6.58, 370.14, 0.19, 384.25], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [456.44, 443.07, 439.71, 444.8, 426.45, 442.49, 430.48, 432.11, 435.1, 426.92, 446.05, 395.78, 447.79, 396.93, 446.05, 385.97, 442.02, 367.52, 433.37, 358.87, 431.64, 347.91, 433.37, 342.92, 435.1, 334.85, 436.83, 327.93, 442.59, 319.85, 448.94, 307.16, 453.55, 292.17, 459.9, 292.75, 468.55, 293.9, 470.85, 307.16, 476.05, 315.82, 484.7, 327.35, 487.0, 338.31, 495.65, 350.42, 499.11, 363.69, 504.31, 374.07, 504.31, 380.41, 499.11, 380.99, 496.23, 380.41, 493.92, 380.41, 493.92, 374.07, 487.0, 365.42, 485.85, 360.22, 480.66, 353.88, 478.35, 361.95, 484.12, 374.64, 491.04, 391.95, 493.35, 399.44, 500.85, 401.75, 500.27, 413.86, 504.31, 420.78, 505.46, 425.97, 507.19, 434.62, 504.31, 444.43, 503.15, 454.23, 497.38, 452.5, 491.62, 432.89, 482.97, 412.71, 470.85, 395.98, 465.09, 396.56, 458.17, 406.36, 450.09, 430.01, 453.55, 435.2, 459.9, 438.66], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [640.0, 283.55, 635.24, 287.03, 636.81, 293.3, 638.03, 294.51, 637.16, 297.3, 632.81, 299.04, 630.54, 303.22, 627.06, 312.45, 627.58, 324.29, 628.8, 334.73, 628.98, 339.78, 628.98, 346.92, 628.28, 356.67, 628.63, 363.81, 632.11, 368.68, 637.33, 370.07, 639.07, 361.02, 637.68, 354.23, 637.86, 349.18, 640.0, 347.96], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [492.94, 438.58, 400.56, 452.54, 391.61, 448.6, 390.9, 445.74, 405.58, 444.67, 431.0, 441.09, 438.87, 442.16, 446.39, 442.16, 453.55, 441.8, 457.85, 440.37, 461.43, 439.29, 463.22, 437.86, 491.15, 435.36, 491.15, 437.5], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [497.95, 455.05, 498.31, 469.01, 509.41, 466.51, 506.54, 447.89, 498.66, 452.9], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [345.15, 306.69, 346.99, 321.41, 345.34, 321.41, 344.23, 308.72, 343.86, 307.43, 344.97, 306.51], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [346.26, 330.99, 345.7, 323.44, 347.36, 323.99, 347.36, 332.09, 345.7, 332.09], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [347.18, 337.24, 346.26, 332.27, 347.91, 332.09, 348.1, 337.06, 347.91, 337.61], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [430.77, 354.35, 428.26, 343.97, 427.55, 337.88, 425.76, 330.72, 426.47, 313.89, 426.11, 306.38, 426.11, 303.51, 425.04, 299.57, 428.26, 295.99, 431.84, 295.63, 433.99, 299.22, 435.78, 306.02, 440.08, 308.17, 441.87, 312.82, 441.15, 317.12, 440.44, 323.56, 438.65, 329.65, 435.42, 335.73, 432.92, 344.69, 432.2, 350.06, 431.84, 357.22], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [182.57, 234.8, 185.11, 233.45, 184.06, 231.66, 184.81, 229.56, 184.96, 227.32, 184.96, 223.58, 185.11, 221.49, 185.71, 218.05, 184.66, 216.41, 183.31, 215.96, 182.87, 213.27, 181.37, 212.97, 181.22, 216.26, 181.37, 220.44, 181.37, 222.69, 181.67, 226.42, 181.82, 229.41, 182.12, 231.66, 182.12, 232.85], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [388.33, 301.16, 388.83, 300.78, 391.47, 302.54, 390.92, 304.53, 390.2, 305.46, 390.09, 308.49, 389.43, 309.04, 389.98, 313.95, 389.93, 314.94, 386.12, 316.34, 385.93, 318.07, 392.92, 318.61, 397.1, 318.61, 399.18, 318.07, 405.08, 318.97, 405.9, 317.61, 403.72, 313.89, 401.82, 312.26, 399.46, 303.0, 399.91, 301.91, 399.91, 301.0, 399.28, 300.37, 398.1, 301.28, 397.19, 302.09, 394.74, 302.37, 392.83, 302.55, 389.11, 300.1], "className": "backpack"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [589.05, 300.11, 585.16, 304.94, 584.69, 306.5, 586.71, 308.68, 590.3, 309.77, 597.31, 306.97, 597.47, 306.19, 594.35, 304.63, 599.81, 301.82, 599.65, 299.95, 597.16, 299.64, 593.1, 302.14, 590.77, 299.64, 589.99, 299.18], "className": "backpack"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [514.44, 296.16, 510.86, 300.32, 511.0, 304.48, 512.29, 304.76, 512.87, 306.91, 512.01, 307.49, 511.15, 309.93, 511.29, 310.79, 507.56, 312.94, 505.98, 326.42, 506.41, 334.59, 506.99, 336.46, 508.13, 336.6, 511.58, 334.16, 510.86, 339.9, 513.15, 344.06, 512.44, 348.93, 514.73, 352.95, 515.3, 356.53, 516.45, 357.39, 516.17, 362.99, 516.88, 366.0, 517.6, 366.86, 520.47, 356.82, 522.05, 350.51, 522.05, 349.51, 519.61, 343.77, 519.18, 339.61, 518.75, 335.45, 519.61, 325.41, 521.33, 316.52, 521.9, 310.93, 522.48, 308.64, 521.61, 308.06, 521.61, 303.9, 521.61, 300.03, 517.03, 296.16, 514.16, 295.87], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [524.19, 351.84, 519.11, 365.55, 518.94, 368.77, 516.57, 372.5, 516.06, 375.89, 524.19, 376.39, 527.75, 376.39, 527.24, 372.33, 526.39, 369.96, 524.19, 367.93, 524.87, 351.33], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [532.49, 413.5, 523.26, 423.81, 523.26, 423.81, 534.66, 424.89, 537.91, 414.04, 537.91, 414.04], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [563.42, 403.73, 541.17, 425.44, 535.2, 425.98, 543.34, 416.75, 559.62, 402.64, 561.79, 403.73], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [585.89, 403.66, 563.23, 398.0, 559.04, 395.29, 556.58, 393.32, 555.84, 390.86, 558.55, 390.37, 561.75, 392.83, 566.19, 395.54, 570.86, 394.31, 574.31, 396.77, 581.7, 398.49, 592.29, 399.72, 596.97, 399.97, 596.23, 402.93, 585.64, 404.4], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [593.03, 398.25, 577.27, 396.52, 572.83, 393.57, 575.3, 393.57, 582.44, 394.8, 588.59, 394.06, 593.52, 393.57, 595.49, 393.81, 597.95, 395.05, 596.47, 398.25], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [382.0, 349.14, 395.64, 351.09, 396.39, 350.49, 383.95, 348.69, 381.4, 348.24, 381.4, 348.24, 381.4, 350.04], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [392.49, 353.63, 405.23, 352.73, 405.98, 351.53, 395.49, 351.83, 395.34, 351.83, 391.44, 352.43, 391.29, 353.33], "className": "skis"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [303, 585, 302, 586, 301, 586, 297, 590, 297, 592, 296, 593, 294, 593, 292, 595, 292, 599, 294, 601, 297, 601, 299, 599, 300, 599, 301, 600, 305, 600, 308, 603, 312, 603, 316, 607, 320, 607, 322, 609, 331, 609, 333, 607, 333, 606, 334, 605, 344, 605, 345, 604, 346, 604, 347, 603, 361, 603, 362, 604, 365, 604, 367, 602, 367, 597, 365, 595, 359, 595, 356, 592, 353, 592, 353, 593, 349, 597, 346, 597, 345, 598, 326, 598, 325, 597, 321, 597, 320, 596, 319, 596, 318, 595, 317, 595, 316, 594, 315, 594, 314, 593, 313, 593, 311, 591, 311, 590, 307, 586, 306, 586, 305, 585], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [469, 502, 467, 504, 467, 508, 469, 510, 472, 510, 474, 508, 474, 504, 472, 502], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [321, 403, 320, 404, 319, 404, 318, 405, 319, 406, 319, 407, 320, 408, 320, 409, 321, 410, 321, 412, 322, 413, 322, 415, 328, 415, 329, 414, 331, 414, 332, 413, 336, 413, 337, 412, 337, 405, 336, 405, 335, 404, 325, 404, 324, 403], "className": "person"}, {"type": "polygon", "pointLabels": {}, "attributes": [], "creationType": "Pre-annotation", "points": [292, 400, 291, 401, 291, 405, 292, 406, 295, 406, 296, 407, 296, 408, 297, 409, 299, 409, 300, 410, 302, 410, 303, 411, 303, 412, 304, 413, 307, 413, 309, 415, 312, 415, 313, 414, 313, 412, 304, 403, 303, 403, 302, 402, 301, 402, 300, 401, 298, 401, 297, 400, 296, 401, 295, 400], "className": "person"}], "metadata": {"name": "000000411530.jpg", "width": 640, "height": 480}, "tags": [], "comments": []}

tests/converter_test/test_conversion.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pathlib import Path
22

3+
from mixpanel import json_dumps
4+
35
import superannotate as sa
46

57

@@ -38,6 +40,14 @@ def test_instance_segmentation_coco2sa(tmpdir):
3840
input_dir, out_path, "COCO", "instances_test", "Vector",
3941
"instance_segmentation"
4042
)
43+
import json
44+
json_path = out_path / "000000411530.jpg___objects.json"
45+
with open(json_path, 'r') as f:
46+
data = json.loads(f.read())
47+
truth_path = input_dir / "truth.json"
48+
with open(truth_path, 'r') as f:
49+
truth = json.loads(f.read())
50+
assert truth == data
4151

4252

4353
# SA to COCO

0 commit comments

Comments
 (0)