yolov8机器视觉-工业质检

使用训练好的模型进行预测

yolo predict task=detect model=训练好的模型路径 source=测试图片文件夹路径 show=True

效果展示

yolov8机器视觉-工业质检_第1张图片
yolov8机器视觉-工业质检_第2张图片
yolov8机器视觉-工业质检_第3张图片
yolov8机器视觉-工业质检_第4张图片
yolov8机器视觉-工业质检_第5张图片

切换模型进行训练(yolov8s)

修改main.py训练参数文件

使用云gpu进行训练,很方便:点击链接转至在线云gpu

yolov8机器视觉-工业质检_第6张图片
修改训练参数:
yolov8机器视觉-工业质检_第7张图片
此文件位于:yolov8-main->ultralytics->datasets->keypoint.yaml

修改训练素材路径位置

yolov8机器视觉-工业质检_第8张图片

安装依赖

yolov8机器视觉-工业质检_第9张图片

修改default.yaml

yolov8机器视觉-工业质检_第10张图片

开启训练

yolov8机器视觉-工业质检_第11张图片



                   from  n    params  module                                       arguments                     
  0                  -1  1       928  ultralytics.nn.modules.conv.Conv             [3, 32, 3, 2]                 
  1                  -1  1     18560  ultralytics.nn.modules.conv.Conv             [32, 64, 3, 2]                
  2                  -1  1     29056  ultralytics.nn.modules.block.C2f             [64, 64, 1, True]             
  3                  -1  1     73984  ultralytics.nn.modules.conv.Conv             [64, 128, 3, 2]               
  4                  -1  2    197632  ultralytics.nn.modules.block.C2f             [128, 128, 2, True]           
  5                  -1  1    295424  ultralytics.nn.modules.conv.Conv             [128, 256, 3, 2]              
  6                  -1  2    788480  ultralytics.nn.modules.block.C2f             [256, 256, 2, True]           
  7                  -1  1   1180672  ultralytics.nn.modules.conv.Conv             [256, 512, 3, 2]              
  8                  -1  1   1838080  ultralytics.nn.modules.block.C2f             [512, 512, 1, True]           
  9                  -1  1    656896  ultralytics.nn.modules.block.SPPF            [512, 512, 5]                 
 10                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 11             [-1, 6]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 12                  -1  1    455008  ultralytics.nn.modules.block.VoVGSCSPC       [768, 256]                    
 13                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 14             [-1, 4]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 15                  -1  1    114864  ultralytics.nn.modules.block.VoVGSCSPC       [384, 128]                    
 16                  -1  1    147712  ultralytics.nn.modules.conv.Conv             [128, 128, 3, 2]              
 17            [-1, 12]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 18                  -1  1    356704  ultralytics.nn.modules.block.VoVGSCSPC       [384, 256]                    
 19                  -1  1    590336  ultralytics.nn.modules.conv.Conv             [256, 256, 3, 2]              
 20             [-1, 9]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 21                  -1  1   1417920  ultralytics.nn.modules.block.VoVGSCSPC       [768, 512]                    
 22        [15, 18, 21]  1   2118757  ultralytics.nn.modules.head.Detect           [7, [128, 256, 512]]          
YOLOv8s summary: 301 layers, 10281013 parameters, 10280997 gradients

New https://pypi.org/project/ultralytics/8.0.168 available  Update with 'pip install -U ultralytics'
Ultralytics YOLOv8.0.118  Python-3.10.12 torch-2.0.1+cu118 CUDA:0 (NVIDIA GeForce RTX 3060, 12044MiB)
yolo/engine/trainer: task=detect, mode=train, model=/home/featurize/work/yolo/yolov8-main/yolov8s.pt, data=/home/featurize/work/yolo/yolov8-main/ultralytics/datasets/keypoint.yaml, epochs=100, patience=50, batch=4, imgsz=640, save=True, save_period=-1, cache=False, device=0, workers=6, project=None, name=None, exist_ok=False, pretrained=False, optimizer=auto, verbose=True, seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False, close_mosaic=0, resume=False, amp=True, fraction=1.0, profile=False, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, show=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, vid_stride=1, line_width=None, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, boxes=True, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, cfg=None, v5loader=False, tracker=botsort.yaml, save_dir=runs/detect/train8
Downloading https://ultralytics.com/assets/Arial.Unicode.ttf to /home/featurize/.config/Ultralytics/Arial.Unicode.ttf...
100%|███████████████████████████████████████| 22.2M/22.2M [00:00<00:00, 279MB/s]
Overriding model.yaml nc=80 with nc=7

                   from  n    params  module                                       arguments                     
  0                  -1  1       928  ultralytics.nn.modules.conv.Conv             [3, 32, 3, 2]                 
  1                  -1  1     18560  ultralytics.nn.modules.conv.Conv             [32, 64, 3, 2]                
  2                  -1  1     29056  ultralytics.nn.modules.block.C2f             [64, 64, 1, True]             
  3                  -1  1     73984  ultralytics.nn.modules.conv.Conv             [64, 128, 3, 2]               
  4                  -1  2    197632  ultralytics.nn.modules.block.C2f             [128, 128, 2, True]           
  5                  -1  1    295424  ultralytics.nn.modules.conv.Conv             [128, 256, 3, 2]              
  6                  -1  2    788480  ultralytics.nn.modules.block.C2f             [256, 256, 2, True]           
  7                  -1  1   1180672  ultralytics.nn.modules.conv.Conv             [256, 512, 3, 2]              
  8                  -1  1   1838080  ultralytics.nn.modules.block.C2f             [512, 512, 1, True]           
  9                  -1  1    656896  ultralytics.nn.modules.block.SPPF            [512, 512, 5]                 
 10                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 11             [-1, 6]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 12                  -1  1    591360  ultralytics.nn.modules.block.C2f             [768, 256, 1]                 
 13                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 14             [-1, 4]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 15                  -1  1    148224  ultralytics.nn.modules.block.C2f             [384, 128, 1]                 
 16                  -1  1    147712  ultralytics.nn.modules.conv.Conv             [128, 128, 3, 2]              
 17            [-1, 12]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 18                  -1  1    493056  ultralytics.nn.modules.block.C2f             [384, 256, 1]                 
 19                  -1  1    590336  ultralytics.nn.modules.conv.Conv             [256, 256, 3, 2]              
 20             [-1, 9]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 21                  -1  1   1969152  ultralytics.nn.modules.block.C2f             [768, 512, 1]                 
 22        [15, 18, 21]  1   2118757  ultralytics.nn.modules.head.Detect           [7, [128, 256, 512]]          
Model summary: 225 layers, 11138309 parameters, 11138293 gradients

Transferred 349/355 items from pretrained weights
TensorBoard: Start with 'tensorboard --logdir runs/detect/train8', view at http://localhost:6006/
AMP: running Automatic Mixed Precision (AMP) checks with YOLOv8n...
AMP: checks passed ✅
train: Scanning /home/featurize/work/yolo/yolov8-main/datasets/injector_datasets
train: New cache created: /home/featurize/work/yolo/yolov8-main/datasets/injector_datasets/labels/trainImages.cache
val: Scanning /home/featurize/work/yolo/yolov8-main/datasets/injector_datasets/l
val: New cache created: /home/featurize/work/yolo/yolov8-main/datasets/injector_datasets/labels/valImages.cache
Plotting labels to runs/detect/train8/labels.jpg... 
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
  self._figure.tight_layout(*args, **kwargs)
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
  if pd.api.types.is_categorical_dtype(vector):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/environment/miniconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1119: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead.
  with pd.option_context('mode.use_inf_as_na', True):
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 33014 (\N{CJK UNIFIED IDEOGRAPH-80F6}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 22622 (\N{CJK UNIFIED IDEOGRAPH-585E}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 25512 (\N{CJK UNIFIED IDEOGRAPH-63A8}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 26438 (\N{CJK UNIFIED IDEOGRAPH-6746}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 23614 (\N{CJK UNIFIED IDEOGRAPH-5C3E}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 37096 (\N{CJK UNIFIED IDEOGRAPH-90E8}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 38024 (\N{CJK UNIFIED IDEOGRAPH-9488}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 22068 (\N{CJK UNIFIED IDEOGRAPH-5634}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 27498 (\N{CJK UNIFIED IDEOGRAPH-6B6A}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 34746 (\N{CJK UNIFIED IDEOGRAPH-87BA}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 21475 (\N{CJK UNIFIED IDEOGRAPH-53E3}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 23567 (\N{CJK UNIFIED IDEOGRAPH-5C0F}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 33014 (\N{CJK UNIFIED IDEOGRAPH-80F6}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 22622 (\N{CJK UNIFIED IDEOGRAPH-585E}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 25512 (\N{CJK UNIFIED IDEOGRAPH-63A8}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 26438 (\N{CJK UNIFIED IDEOGRAPH-6746}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 23614 (\N{CJK UNIFIED IDEOGRAPH-5C3E}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 37096 (\N{CJK UNIFIED IDEOGRAPH-90E8}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 38024 (\N{CJK UNIFIED IDEOGRAPH-9488}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 22068 (\N{CJK UNIFIED IDEOGRAPH-5634}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 27498 (\N{CJK UNIFIED IDEOGRAPH-6B6A}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 34746 (\N{CJK UNIFIED IDEOGRAPH-87BA}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 21475 (\N{CJK UNIFIED IDEOGRAPH-53E3}) missing from current font.
  plt.savefig(fname, dpi=200)
/home/featurize/work/yolo/yolov8-main/ultralytics/yolo/utils/plotting.py:276: UserWarning: Glyph 23567 (\N{CJK UNIFIED IDEOGRAPH-5C0F}) missing from current font.
  plt.savefig(fname, dpi=200)
optimizer: AdamW(lr=0.000909, momentum=0.9) with parameter groups 57 weight(decay=0.0), 64 weight(decay=0.0005), 63 bias(decay=0.0)
Image sizes 640 train, 640 val
Using 4 dataloader workers
Logging results to runs/detect/train8
Starting training for 100 epochs...

      Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
      1/100      1.49G      7.714      9.472      1.749         97        640:  Downloading https://ultralytics.com/assets/Arial.ttf to /home/featurize/.config/Ultralytics/Arial.ttf...
      1/100      1.49G      7.788       9.67      1.762         80        640:  Downloading https://ultralytics.com/assets/Arial.ttf to /home/featurize/.config/Ultralytics/Arial.ttf...
      1/100      1.49G      7.561      9.627      1.769         39        640:  Downloading https://ultralytics.com/assets/Arial.ttf to /home/featurize/.config/Ultralytics/Arial.ttf...
      1/100      1.49G      7.513      9.496      1.781         47        640:  
100%|█████████████████████████████████████████| 755k/755k [00:00<00:00, 195MB/s]

  0%|                                                | 0.00/755k [00:00

观察mAP50,在第三个Epoch时,已经达到了0.8,从第8个Epoch开始,已经稳定在了0.9,收敛很快
模型最终保存到了Results saved to runs/detect/train8

模型转换

yolov8机器视觉-工业质检_第12张图片
修改main.py文件,mode更改为 onnx,并且model路径更改为训练好的模型地址,执行python main.py即可
执行完毕后将会在刚训练好的模型路径下生成转换后的onnx模型文件
yolov8机器视觉-工业质检_第13张图片

使用yolov8s预训练模型训练的模型再试试我们的预测

yolo predict task=detect model=runs/yolov8s/best.pt source=datasets/injector_datasets/images/testImages show=True

yolov8机器视觉-工业质检_第14张图片
yolov8机器视觉-工业质检_第15张图片
yolov8机器视觉-工业质检_第16张图片
yolov8机器视觉-工业质检_第17张图片
yolov8机器视觉-工业质检_第18张图片

预测效果还是很不错的

你可能感兴趣的:(yolo,YOLO,深度学习,人工智能)