MCPcopy
hub / github.com/dbolya/yolact / evaluate

Function evaluate

eval.py:870–1003  ·  view source on GitHub ↗
(net:Yolact, dataset, train_mode=False)

Source from the content-addressed store, hash-verified

868 cleanup_and_exit()
869
870def evaluate(net:Yolact, dataset, train_mode=False):
871 net.detect.use_fast_nms = args.fast_nms
872 net.detect.use_cross_class_nms = args.cross_class_nms
873 cfg.mask_proto_debug = args.mask_proto_debug
874
875 # TODO Currently we do not support Fast Mask Re-scroing in evalimage, evalimages, and evalvideo
876 if args.image is not None:
877 if ':' in args.image:
878 inp, out = args.image.split(':')
879 evalimage(net, inp, out)
880 else:
881 evalimage(net, args.image)
882 return
883 elif args.images is not None:
884 inp, out = args.images.split(':')
885 evalimages(net, inp, out)
886 return
887 elif args.video is not None:
888 if ':' in args.video:
889 inp, out = args.video.split(':')
890 evalvideo(net, inp, out)
891 else:
892 evalvideo(net, args.video)
893 return
894
895 frame_times = MovingAverage()
896 dataset_size = len(dataset) if args.max_images < 0 else min(args.max_images, len(dataset))
897 progress_bar = ProgressBar(30, dataset_size)
898
899 print()
900
901 if not args.display and not args.benchmark:
902 # For each class and iou, stores tuples (score, isPositive)
903 # Index ap_data[type][iouIdx][classIdx]
904 ap_data = {
905 'box' : [[APDataObject() for _ in cfg.dataset.class_names] for _ in iou_thresholds],
906 'mask': [[APDataObject() for _ in cfg.dataset.class_names] for _ in iou_thresholds]
907 }
908 detections = Detections()
909 else:
910 timer.disable('Load Data')
911
912 dataset_indices = list(range(len(dataset)))
913
914 if args.shuffle:
915 random.shuffle(dataset_indices)
916 elif not args.no_sort:
917 # Do a deterministic shuffle based on the image ids
918 #
919 # I do this because on python 3.5 dictionary key order is *random*, while in 3.6 it's
920 # the order of insertion. That means on python 3.6, the images come in the order they are in
921 # in the annotations file. For some reason, the first images in the annotations file are
922 # the hardest. To combat this, I use a hard-coded hash function based on the image ids
923 # to shuffle the indices we use. That way, no matter what python version or how pycocotools
924 # handles the data, we get the same result every time.
925 hashed = [badhash(x) for x in dataset.ids]
926 dataset_indices.sort(key=lambda x: hashed[x])
927

Callers 1

eval.pyFile · 0.85

Calls 15

addMethod · 0.95
get_avgMethod · 0.95
set_valMethod · 0.95
dump_webMethod · 0.95
dumpMethod · 0.95
MovingAverageClass · 0.90
ProgressBarClass · 0.90
evalimageFunction · 0.85
evalimagesFunction · 0.85
evalvideoFunction · 0.85
APDataObjectClass · 0.85
DetectionsClass · 0.85

Tested by

no test coverage detected