MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / create_instances

Function create_instances

tools/visualize_json_results.py:19–38  ·  view source on GitHub ↗
(predictions, image_size)

Source from the content-addressed store, hash-verified

17
18
19def create_instances(predictions, image_size):
20 ret = Instances(image_size)
21
22 score = np.asarray([x["score"] for x in predictions])
23 chosen = (score > args.conf_threshold).nonzero()[0]
24 score = score[chosen]
25 bbox = np.asarray([predictions[i]["bbox"] for i in chosen]).reshape(-1, 4)
26 bbox = BoxMode.convert(bbox, BoxMode.XYWH_ABS, BoxMode.XYXY_ABS)
27
28 labels = np.asarray([dataset_id_map(predictions[i]["category_id"]) for i in chosen])
29
30 ret.scores = score
31 ret.pred_boxes = Boxes(bbox)
32 ret.pred_classes = labels
33
34 try:
35 ret.pred_masks = [predictions[i]["segmentation"] for i in chosen]
36 except KeyError:
37 pass
38 return ret
39
40
41if __name__ == "__main__":

Callers 1

Calls 4

InstancesClass · 0.90
BoxesClass · 0.90
dataset_id_mapFunction · 0.85
convertMethod · 0.80

Tested by

no test coverage detected