glenn-jocher commited on
Commit
659ad74
1 Parent(s): fd0b1cc

update get_voc.sh

Browse files
Files changed (4) hide show
  1. Dockerfile +1 -1
  2. data/get_voc.sh +1 -1
  3. detect.py +3 -3
  4. models/export.py +12 -0
Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
  # Start FROM Nvidia PyTorch image https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
2
- FROM nvcr.io/nvidia/pytorch:20.06-py3
3
  RUN pip install -U gsutil
4
 
5
  # Create working directory
 
1
  # Start FROM Nvidia PyTorch image https://ngc.nvidia.com/catalog/containers/nvidia:pytorch
2
+ FROM nvcr.io/nvidia/pytorch:20.03-py3
3
  RUN pip install -U gsutil
4
 
5
  # Create working directory
data/get_voc.sh CHANGED
@@ -1,5 +1,5 @@
1
  # PASCAL VOC dataset http://host.robots.ox.ac.uk/pascal/VOC/
2
- # Download command: bash yolov5/data/get_voc.sh
3
  # Train command: python train.py --data voc.yaml
4
  # Dataset should be placed next to yolov5 folder:
5
  # /parent_folder
 
1
  # PASCAL VOC dataset http://host.robots.ox.ac.uk/pascal/VOC/
2
+ # Download command: bash ./data/get_voc.sh
3
  # Train command: python train.py --data voc.yaml
4
  # Dataset should be placed next to yolov5 folder:
5
  # /parent_folder
detect.py CHANGED
@@ -102,7 +102,7 @@ def detect(save_img=False):
102
 
103
  if save_img or view_img: # Add bbox to image
104
  label = '%s %.2f' % (names[int(cls)], conf)
105
- plot_one_box(xyxy, im0, label=label, color=colors[int(cls)], line_thickness=3)
106
 
107
  # Print time (inference + NMS)
108
  print('%sDone. (%.3fs)' % (s, t2 - t1))
@@ -139,10 +139,10 @@ def detect(save_img=False):
139
 
140
  if __name__ == '__main__':
141
  parser = argparse.ArgumentParser()
142
- parser.add_argument('--weights', type=str, default='weights/yolov5s.pt', help='model.pt path')
143
  parser.add_argument('--source', type=str, default='inference/images', help='source') # file/folder, 0 for webcam
144
  parser.add_argument('--output', type=str, default='inference/output', help='output folder') # output folder
145
- parser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)')
146
  parser.add_argument('--conf-thres', type=float, default=0.4, help='object confidence threshold')
147
  parser.add_argument('--iou-thres', type=float, default=0.5, help='IOU threshold for NMS')
148
  parser.add_argument('--fourcc', type=str, default='mp4v', help='output video codec (verify ffmpeg support)')
 
102
 
103
  if save_img or view_img: # Add bbox to image
104
  label = '%s %.2f' % (names[int(cls)], conf)
105
+ plot_one_box(xyxy, im0, label=label, color=colors[int(cls)], line_thickness=1)
106
 
107
  # Print time (inference + NMS)
108
  print('%sDone. (%.3fs)' % (s, t2 - t1))
 
139
 
140
  if __name__ == '__main__':
141
  parser = argparse.ArgumentParser()
142
+ parser.add_argument('--weights', type=str, default='weights/yolov5m.pt', help='model.pt path')
143
  parser.add_argument('--source', type=str, default='inference/images', help='source') # file/folder, 0 for webcam
144
  parser.add_argument('--output', type=str, default='inference/output', help='output folder') # output folder
145
+ parser.add_argument('--img-size', type=int, default=1024, help='inference size (pixels)')
146
  parser.add_argument('--conf-thres', type=float, default=0.4, help='object confidence threshold')
147
  parser.add_argument('--iou-thres', type=float, default=0.5, help='IOU threshold for NMS')
148
  parser.add_argument('--fourcc', type=str, default='mp4v', help='output video codec (verify ffmpeg support)')
models/export.py CHANGED
@@ -56,5 +56,17 @@ if __name__ == '__main__':
56
  except Exception as e:
57
  print('ONNX export failure: %s' % e)
58
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  # Finish
60
  print('\nExport complete. Visualize with https://github.com/lutzroeder/netron.')
 
56
  except Exception as e:
57
  print('ONNX export failure: %s' % e)
58
 
59
+ # CoreML export
60
+ try:
61
+ import coremltools as ct
62
+
63
+ print('\nStarting CoreML export with coremltools %s...' % ct.__version__)
64
+ model = ct.convert(ts, inputs=[ct.ImageType(name='images', shape=img.shape)]) # convert
65
+ f = opt.weights.replace('.pt', '.mlmodel') # filename
66
+ model.save(f)
67
+ print('CoreML export success, saved as %s' % f)
68
+ except Exception as e:
69
+ print('CoreML export failure: %s' % e)
70
+
71
  # Finish
72
  print('\nExport complete. Visualize with https://github.com/lutzroeder/netron.')