当前位置:   article > 正文

yolov5的flask部署python调用_from models.experimental import attempt_load

from models.experimental import attempt_load

yolov5 github:https://github.com/ultralytics/yolov5
跟踪:https://github.com/mikel-brostrom/Yolov5_DeepSort_Pytorch
TensorRT:https://github.com/TrojanXu/yolov5-tensorrt
NCNN:https://github.com/WZTENG/YOLOv5_NCNN

detect:

  1. from torchvision import transforms
  2. import torch
  3. from PIL import Image,ImageDraw
  4. from models import yolo
  5. from utils.general import non_max_suppression
  6. from models.experimental import attempt_load
  7. # model = yolo.Model(r"D:\GoogleEarthProPortable\yolov5-master\models\yolov5s.yaml")
  8. # model.load_state_dict(torch.load(r"D:\GoogleEarthProPortable\yolov5-master\weights\yolov5s.pt"))
  9. model = attempt_load("weights/yolov5s.pt") # load FP32 model
  10. model.eval()
  11. img = Image.open("inference/images/bus.jpg")
  12. tf = transforms.Compose([
  13. transforms.Resize((512,640)),
  14. transforms.ToTensor()
  15. ])
  16. print(img.size) # w,h
  17. scale_w = img.size[0] /640
  18. scale_h = img
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/358375
推荐阅读
相关标签
  

闽ICP备14008679号