Commit 4fd43377 authored by Ubuntu's avatar Ubuntu
Browse files

Fixed problem with segments with 2 points interpreted as bbox

parent 3f3158d1
......@@ -25,6 +25,9 @@ def evaluate(test_images_path, predictions_output_path):
image_id = int(os.path.basename(image).replace(".jpg", ""))
for prediction in output:
prediction["image_id"] = image_id
# Fix https://github.com/cocodataset/cocoapi/issues/139
# i.e. remove all segments with less than 3 points
prediction["segmentation"] = [s for s in prediction["segmentation"] if len(s) > 4]
predictions.append(prediction)
count += 1
if test and count == 4:
......
......@@ -2473,7 +2473,7 @@ class MaskRCNN():
# Run object detection
detections, _, _, mrcnn_mask, _, _, _ =\
self.keras_model.predict([molded_images, image_metas, anchors], verbose=0)
print(detections)
# print(detections)
# Process detections
results = []
for i, image in enumerate(images):
......
[{"category_id": 1026, "segmentation": [[169.0, 445.5, 139.0, 443.5, 80.0, 426.5, 58.0, 415.5, 51.5, 407.0, 40.5, 381.0, 32.5, 350.0, 23.5, 336.0, 21.5, 202.0, 27.5, 154.0, 43.0, 131.5, 58.0, 127.5, 73.0, 114.5, 121.0, 94.5, 147.0, 87.5, 164.0, 86.5, 181.0, 77.5, 207.0, 71.5, 243.0, 68.5, 283.0, 73.5, 300.0, 83.5, 315.0, 85.5, 331.0, 100.5, 345.0, 107.5, 353.0, 117.5, 378.0, 128.5, 391.0, 129.5, 408.0, 144.5, 421.5, 150.0, 431.5, 180.0, 431.5, 194.0, 438.5, 208.0, 441.5, 294.0, 437.5, 321.0, 423.5, 349.0, 409.0, 367.5, 396.0, 375.5, 378.0, 395.5, 356.0, 404.5, 330.0, 422.5, 315.0, 428.5, 287.0, 433.5, 251.0, 431.5, 169.0, 445.5], [347.5, 226.0, 373.0, 212.5, 376.5, 206.0, 367.5, 194.0, 374.5, 179.0, 368.0, 170.5, 358.5, 166.0, 363.5, 151.0, 350.5, 141.0, 346.0, 132.5, 333.0, 141.5, 320.0, 140.5, 315.0, 136.5, 310.0, 142.5, 292.0, 148.5, 269.5, 166.0, 270.0, 196.5, 282.0, 200.5, 287.0, 208.5, 309.0, 217.5, 316.0, 224.5, 347.5, 226.0], [242.5, 382.0, 254.0, 378.5, 270.0, 378.5, 277.0, 368.5, 285.5, 365.0, 280.5, 353.0, 285.5, 335.0, 275.0, 329.5, 255.0, 310.5, 240.0, 322.5, 231.0, 320.5, 225.0, 312.5, 222.5, 322.0, 206.5, 335.0, 221.5, 379.0, 242.5, 382.0]], "score": 0.49339866638183594, "bbox": [21.0, 59.0, 423.0, 399.0], "image_id": 32275}, {"category_id": 1069, "segmentation": [[355.0, 241.5, 340.0, 241.5, 333.0, 238.5, 326.0, 225.5, 308.0, 214.5, 299.0, 212.5, 283.0, 214.5, 276.0, 223.5, 261.0, 229.5, 259.0, 225.5, 247.5, 220.0, 238.5, 201.0, 231.5, 194.0, 236.5, 184.0, 232.5, 171.0, 254.0, 164.5, 261.0, 155.5, 276.0, 148.5, 303.0, 144.5, 331.0, 148.5, 338.0, 159.5, 354.5, 171.0, 353.0, 183.5, 375.0, 184.5, 383.5, 193.0, 383.5, 226.0, 371.0, 236.5, 355.0, 241.5], [269.0, 238.5, 266.5, 237.0, 269.0, 229.5, 269.0, 238.5], [253.0, 240.5, 248.5, 237.0, 251.0, 232.5, 257.5, 235.0, 253.0, 240.5], [165.0, 282.5, 146.5, 278.0, 144.5, 256.0, 147.0, 234.5, 163.0, 239.5, 184.0, 254.5, 203.5, 259.0, 202.5, 273.0, 193.0, 281.5, 173.0, 279.5, 165.0, 282.5], [270.0, 264.5, 265.5, 259.0, 269.0, 253.5, 287.5, 259.0, 270.0, 264.5], [284.0, 282.5, 268.5, 281.0, 287.5, 281.0, 284.0, 282.5], [280.0, 385.5, 221.0, 383.5, 211.0, 380.5, 205.0, 373.5, 199.0, 371.5, 181.5, 325.0, 184.5, 315.0, 183.5, 300.0, 198.0, 293.5, 210.0, 295.5, 226.0, 301.5, 233.5, 315.0, 244.0, 320.5, 269.0, 321.5, 278.0, 316.5, 286.0, 323.5, 285.5, 336.0, 295.0, 335.5, 305.5, 346.0, 314.5, 366.0, 314.5, 376.0, 313.0, 380.5, 280.0, 385.5], [278.0, 303.5, 278.0, 303.5]], "score": 0.26003336906433105, "bbox": [143.0, 78.0, 245.0, 308.0], "image_id": 32275}, {"category_id": 1040, "segmentation": [[105.0, 367.5, 59.0, 364.5, 52.5, 362.0, 49.5, 354.0, 49.5, 325.0, 59.5, 301.0, 61.5, 276.0, 51.5, 265.0, 46.5, 242.0, 46.5, 154.0, 51.5, 129.0, 68.5, 106.0, 92.0, 79.5, 105.0, 73.5, 112.0, 65.5, 140.0, 46.5, 172.0, 33.5, 197.0, 28.5, 275.0, 29.5, 287.0, 35.5, 303.0, 36.5, 319.0, 44.5, 332.0, 45.5, 346.0, 55.5, 364.0, 62.5, 380.5, 80.0, 387.5, 93.0, 389.5, 128.0, 401.5, 163.0, 423.5, 180.0, 441.5, 215.0, 443.5, 242.0, 439.5, 264.0, 430.5, 276.0, 427.5, 290.0, 421.5, 299.0, 392.0, 325.5, 375.0, 333.5, 362.0, 323.5, 347.0, 324.5, 332.5, 293.0, 304.0, 280.5, 287.0, 279.5, 259.0, 288.5, 217.0, 288.5, 199.0, 284.5, 184.0, 293.5, 169.0, 292.5, 147.0, 301.5, 140.5, 308.0, 136.5, 322.0, 136.5, 352.0, 133.5, 362.0, 125.0, 366.5, 105.0, 367.5]], "score": 0.5733943581581116, "bbox": [45.0, 26.0, 413.0, 343.0], "image_id": 34253}, {"category_id": 2099, "segmentation": [[272.0, 445.5, 168.0, 444.5, 146.0, 440.5, 149.5, 436.0, 145.5, 432.0, 153.5, 429.0, 147.5, 424.0, 150.5, 421.0, 147.0, 417.5, 137.0, 419.5, 129.0, 416.5, 119.5, 408.0, 118.5, 386.0, 121.5, 370.0, 157.0, 350.5, 203.0, 339.5, 289.0, 339.5, 322.0, 348.5, 332.5, 356.0, 338.5, 366.0, 332.5, 392.0, 333.5, 402.0, 328.5, 416.0, 320.0, 428.5, 315.0, 428.5, 307.0, 436.5, 272.0, 445.5]], "score": 0.7990953922271729, "bbox": [118.0, 339.0, 234.0, 107.0], "image_id": 34253}, {"category_id": 1566, "segmentation": [[632.0, 684.5, 614.0, 680.5, 606.0, 675.5, 594.0, 677.5, 573.0, 668.5, 564.0, 658.5, 524.0, 632.5, 508.0, 609.5, 494.5, 606.0, 481.5, 558.0, 479.5, 509.0, 480.5, 479.0, 487.5, 444.0, 499.5, 430.0, 503.5, 408.0, 514.5, 395.0, 528.5, 368.0, 546.0, 352.5, 582.0, 335.5, 605.0, 329.5, 640.0, 326.5, 668.0, 337.5, 680.0, 349.5, 692.0, 351.5, 704.0, 361.5, 717.0, 364.5, 730.0, 380.5, 744.5, 387.0, 754.0, 406.5, 766.0, 405.5, 779.0, 420.5, 794.0, 425.5, 802.5, 438.0, 806.5, 463.0, 802.5, 476.0, 805.5, 499.0, 801.5, 514.0, 801.5, 535.0, 787.5, 552.0, 790.5, 570.0, 773.5, 588.0, 772.5, 608.0, 752.0, 621.5, 741.0, 622.5, 729.0, 643.5, 717.0, 641.5, 705.0, 651.5, 692.0, 654.5, 684.5, 660.0, 679.0, 669.5, 668.0, 671.5, 656.0, 681.5, 639.0, 681.5, 632.0, 684.5]], "score": 0.6491364240646362, "bbox": [478.0, 275.0, 344.0, 501.0], "image_id": 16677}, {"category_id": 1566, "segmentation": [[360.0, 253.5, 339.0, 253.5, 311.0, 247.5, 301.0, 239.5, 291.0, 236.5, 263.0, 211.5, 253.0, 208.5, 243.0, 196.5, 234.0, 195.5, 224.0, 185.5, 214.0, 183.5, 204.0, 169.5, 195.0, 167.5, 174.5, 146.0, 162.5, 118.0, 154.5, 84.0, 173.5, 40.0, 183.0, 30.5, 195.0, 21.5, 214.0, 13.5, 307.0, 13.5, 331.0, 18.5, 360.0, 30.5, 379.0, 45.5, 390.5, 59.0, 397.5, 71.0, 400.5, 84.0, 400.5, 217.0, 397.5, 227.0, 381.0, 243.5, 360.0, 253.5]], "score": 0.6506842970848083, "bbox": [133.0, 12.0, 269.0, 245.0], "image_id": 36985}, {"category_id": 1310, "segmentation": [[125.0, 417.5, 116.0, 410.5, 108.0, 414.5, 74.5, 371.0, 73.5, 363.0, 64.0, 366.5, 53.5, 356.0, 55.5, 348.0, 47.5, 340.0, 44.5, 319.0, 44.5, 302.0, 49.5, 289.0, 56.0, 282.5, 64.0, 281.5, 73.0, 298.5, 82.0, 295.5, 91.0, 302.5, 99.5, 295.0, 88.5, 266.0, 95.5, 244.0, 101.0, 239.5, 132.0, 230.5, 152.0, 232.5, 185.0, 251.5, 195.0, 246.5, 204.0, 250.5, 212.0, 238.5, 231.0, 235.5, 255.0, 239.5, 265.0, 251.5, 273.0, 252.5, 276.5, 266.0, 276.5, 314.0, 273.5, 379.0, 268.5, 385.0, 247.0, 395.5, 231.0, 399.5, 221.0, 396.5, 199.0, 397.5, 187.0, 392.5, 160.0, 400.5, 152.0, 399.5, 144.0, 410.5, 134.0, 409.5, 125.0, 417.5], [81.0, 291.5, 82.0, 286.5, 81.0, 291.5]], "score": 0.9448469281196594, "bbox": [34.0, 208.0, 244.0, 213.0], "image_id": 36985}]
\ No newline at end of file
[{"category_id": 1026, "segmentation": [[169.0, 445.5, 139.0, 443.5, 80.0, 426.5, 58.0, 415.5, 51.5, 407.0, 40.5, 381.0, 32.5, 350.0, 23.5, 336.0, 21.5, 202.0, 27.5, 154.0, 43.0, 131.5, 58.0, 127.5, 73.0, 114.5, 121.0, 94.5, 147.0, 87.5, 164.0, 86.5, 181.0, 77.5, 207.0, 71.5, 243.0, 68.5, 283.0, 73.5, 300.0, 83.5, 315.0, 85.5, 331.0, 100.5, 345.0, 107.5, 353.0, 117.5, 378.0, 128.5, 391.0, 129.5, 408.0, 144.5, 421.5, 150.0, 431.5, 180.0, 431.5, 194.0, 438.5, 208.0, 441.5, 294.0, 437.5, 321.0, 423.5, 349.0, 409.0, 367.5, 396.0, 375.5, 378.0, 395.5, 356.0, 404.5, 330.0, 422.5, 315.0, 428.5, 287.0, 433.5, 251.0, 431.5, 169.0, 445.5], [347.5, 226.0, 373.0, 212.5, 376.5, 206.0, 367.5, 194.0, 374.5, 179.0, 368.0, 170.5, 358.5, 166.0, 363.5, 151.0, 350.5, 141.0, 346.0, 132.5, 333.0, 141.5, 320.0, 140.5, 315.0, 136.5, 310.0, 142.5, 292.0, 148.5, 269.5, 166.0, 270.0, 196.5, 282.0, 200.5, 287.0, 208.5, 309.0, 217.5, 316.0, 224.5, 347.5, 226.0], [242.5, 382.0, 254.0, 378.5, 270.0, 378.5, 277.0, 368.5, 285.5, 365.0, 280.5, 353.0, 285.5, 335.0, 275.0, 329.5, 255.0, 310.5, 240.0, 322.5, 231.0, 320.5, 225.0, 312.5, 222.5, 322.0, 206.5, 335.0, 221.5, 379.0, 242.5, 382.0]], "score": 0.49339866638183594, "bbox": [21.0, 59.0, 423.0, 399.0], "image_id": 32275}, {"category_id": 1069, "segmentation": [[355.0, 241.5, 340.0, 241.5, 333.0, 238.5, 326.0, 225.5, 308.0, 214.5, 299.0, 212.5, 283.0, 214.5, 276.0, 223.5, 261.0, 229.5, 259.0, 225.5, 247.5, 220.0, 238.5, 201.0, 231.5, 194.0, 236.5, 184.0, 232.5, 171.0, 254.0, 164.5, 261.0, 155.5, 276.0, 148.5, 303.0, 144.5, 331.0, 148.5, 338.0, 159.5, 354.5, 171.0, 353.0, 183.5, 375.0, 184.5, 383.5, 193.0, 383.5, 226.0, 371.0, 236.5, 355.0, 241.5], [269.0, 238.5, 266.5, 237.0, 269.0, 229.5, 269.0, 238.5], [253.0, 240.5, 248.5, 237.0, 251.0, 232.5, 257.5, 235.0, 253.0, 240.5], [165.0, 282.5, 146.5, 278.0, 144.5, 256.0, 147.0, 234.5, 163.0, 239.5, 184.0, 254.5, 203.5, 259.0, 202.5, 273.0, 193.0, 281.5, 173.0, 279.5, 165.0, 282.5], [270.0, 264.5, 265.5, 259.0, 269.0, 253.5, 287.5, 259.0, 270.0, 264.5], [284.0, 282.5, 268.5, 281.0, 287.5, 281.0, 284.0, 282.5], [280.0, 385.5, 221.0, 383.5, 211.0, 380.5, 205.0, 373.5, 199.0, 371.5, 181.5, 325.0, 184.5, 315.0, 183.5, 300.0, 198.0, 293.5, 210.0, 295.5, 226.0, 301.5, 233.5, 315.0, 244.0, 320.5, 269.0, 321.5, 278.0, 316.5, 286.0, 323.5, 285.5, 336.0, 295.0, 335.5, 305.5, 346.0, 314.5, 366.0, 314.5, 376.0, 313.0, 380.5, 280.0, 385.5]], "score": 0.26003336906433105, "bbox": [143.0, 78.0, 245.0, 308.0], "image_id": 32275}]
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment