MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / evaluate_rcnn

Function evaluate_rcnn

sotabench/sotabench.py:42–85  ·  view source on GitHub ↗
(model_name, paper_arxiv_id, cfg_list, model_file)

Source from the content-addressed store, hash-verified

40
41
42def evaluate_rcnn(model_name, paper_arxiv_id, cfg_list, model_file):
43 evaluator = COCOEvaluator(
44 root=COCO_ROOT, model_name=model_name, paper_arxiv_id=paper_arxiv_id
45 )
46 category_id_to_coco_id = {
47 v: k for k, v in COCODetection.COCO_id_to_category_id.items()
48 }
49
50 cfg.update_args(cfg_list) # TODO backup/restore config
51 finalize_configs(False)
52 MODEL = ResNetFPNModel() if cfg.MODE_FPN else ResNetC4Model()
53 predcfg = PredictConfig(
54 model=MODEL,
55 session_init=SmartInit(model_file),
56 input_names=MODEL.get_inference_tensor_names()[0],
57 output_names=MODEL.get_inference_tensor_names()[1],
58 )
59 predictor = OfflinePredictor(predcfg)
60
61 def xyxy_to_xywh(box):
62 box[2] -= box[0]
63 box[3] -= box[1]
64 return box
65
66 df = get_eval_dataflow("coco_val2017")
67 df.reset_state()
68 for img, img_id in tqdm.tqdm(df, total=len(df)):
69 results = predict_image(img, predictor)
70 res = [
71 {
72 "image_id": img_id,
73 "category_id": category_id_to_coco_id.get(
74 int(r.class_id), int(r.class_id)
75 ),
76 "bbox": xyxy_to_xywh([round(float(x), 4) for x in r.box]),
77 "score": round(float(r.score), 3),
78 }
79 for r in results
80 ]
81 evaluator.add(res)
82 if evaluator.cache_exists:
83 break
84
85 evaluator.save()
86
87
88download(

Callers 1

sotabench.pyFile · 0.85

Calls 15

finalize_configsFunction · 0.90
ResNetFPNModelClass · 0.90
ResNetC4ModelClass · 0.90
PredictConfigClass · 0.90
SmartInitFunction · 0.90
OfflinePredictorClass · 0.90
get_eval_dataflowFunction · 0.90
predict_imageFunction · 0.90
xyxy_to_xywhFunction · 0.85
update_argsMethod · 0.80
reset_stateMethod · 0.45

Tested by

no test coverage detected