Skip to content

Commit

Permalink
allow starting without predictions (to only inspect GT)
Browse files Browse the repository at this point in the history
  • Loading branch information
bertsky committed Oct 22, 2021
1 parent d5e5afc commit 9475b15
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions coco_explorer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import json
import os
import re

Expand All @@ -13,9 +14,15 @@

@st.cache(allow_output_mutation=True)
def get_inspector(coco_train, coco_predictions, images_path, eval_type, iou_min, iou_max):
coco = COCO(coco_train)
coco_dt = coco.loadRes(coco_predictions)
inspector = CoCoInspector(coco, coco_dt, base_path=images_path,
coco_gt = COCO(coco_train)
if coco_predictions is None:
coco_dt = coco_gt
else:
coco = json.load(open(coco_predictions))
if isinstance(coco, dict) and 'annotations' in coco:
coco = coco['annotations']
coco_dt = coco.loadRes(coco)
inspector = CoCoInspector(coco_gt, coco_dt, base_path=images_path,
iou_type=eval_type, iou_min=iou_min, iou_max=iou_max)
inspector.evaluate()
inspector.calculate_stats()
Expand Down Expand Up @@ -192,7 +199,7 @@ def app(args):
parser = argparse.ArgumentParser()
parser.add_argument("--coco_train", type=str, required=True, metavar="PATH/TO/COCO.json",
help="COCO dataset to inspect")
parser.add_argument("--coco_predictions", type=str, required=True, metavar="PATH/TO/COCO.json",
parser.add_argument("--coco_predictions", type=str, default=None, metavar="PATH/TO/COCO.json",
help="COCO annotations to compare to")
parser.add_argument("--images_path", type=str, default=os.getcwd(), metavar="PATH/TO/IMAGES/",
help="Directory path to prepend to file_name paths in COCO")
Expand Down

0 comments on commit 9475b15

Please sign in to comment.