You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

shufflenetv2.py 565 B

12345678910111213141516171819202122232425
  1. # Copyright 2020 Tencent
  2. # SPDX-License-Identifier: BSD-3-Clause
  3. import sys
  4. import cv2
  5. from ncnn.model_zoo import get_model
  6. from ncnn.utils import print_topk
  7. if __name__ == "__main__":
  8. if len(sys.argv) != 2:
  9. print("Usage: %s [imagepath]\n" % (sys.argv[0]))
  10. sys.exit(0)
  11. imagepath = sys.argv[1]
  12. m = cv2.imread(imagepath)
  13. if m is None:
  14. print("cv2.imread %s failed\n" % (imagepath))
  15. sys.exit(0)
  16. net = get_model("shufflenetv2", num_threads=4, use_gpu=True)
  17. cls_scores = net(m)
  18. print_topk(cls_scores, 3)