Bắt đầu

Bộ dữ liệu ImageNet

Bộ dữ liệu Ultralytics ImageNet (data="imagenet") là tập con ImageNet-1k / ILSVRC-2012 được dùng để huấn luyện và đánh giá benchmark cho các model phân loại ảnh. Bộ dữ liệu chứa 1.000 lớp đối tượng, với 1.281.167 ảnh huấn luyện và 50.000 ảnh validation, thường được huấn luyện ở kích thước ảnh 224x224 và tải xuống với dung lượng khoảng 144 GB. Cơ sở dữ liệu ImageNet rộng hơn có quy mô lớn hơn nhiều — hơn 14 triệu ảnh độ phân giải cao được gán nhãn bằng các synset WordNet thuộc hơn 20.000 danh mục — nhưng Ultralytics huấn luyện trên tập con ILSVRC tiêu chuẩn gồm 1.000 lớp, tập dữ liệu đã trở thành benchmark mặc định cho deep learning trong thị giác máy tính.

Model ImageNet được huấn luyện trước#

Modelkích thước
(pixel)
acc
top1
acc
top5
Tốc độ
CPU ONNX
(ms)
Tốc độ
T4 TensorRT10
(ms)
params
(M)
FLOPs
(B) ở 224
YOLO26n-cls22471.490.15.0 ± 0.31.1 ± 0.02.80.4
YOLO26s-cls22476.092.97.9 ± 0.21.3 ± 0.06.71.5
YOLO26m-cls22478.194.217.2 ± 0.42.0 ± 0.011.64.8
YOLO26l-cls22479.094.623.2 ± 0.32.8 ± 0.014.16.0
YOLO26x-cls22479.995.041.4 ± 0.93.8 ± 0.029.613.5

Tính năng chính#

  • Bộ dữ liệu Ultralytics imagenet cung cấp 1.000 lớp với 1.281.167 ảnh huấn luyện và 50.000 ảnh validation (ILSVRC-2012), benchmark tiền huấn luyện tiêu chuẩn cho phân loại ảnh.
  • Các lớp được tổ chức theo hệ phân cấp WordNet, trong đó mỗi lớp tương ứng với một synset (một tập hợp các từ đồng nghĩa).
  • Các model thường được huấn luyện ở kích thước 224x224, và tải xuống toàn bộ bộ dữ liệu cần khoảng ~144 GB.
  • Cuộc thi Nhận dạng Hình ảnh Quy mô Lớn ImageNet (ILSVRC) thường niên đã đóng vai trò quan trọng trong việc thúc đẩy nghiên cứu thị giác máy tính.

Cấu trúc dataset#

Bộ dữ liệu Ultralytics ImageNet sử dụng cách chia tập ILSVRC-2012:

Tập dữ liệuHình ảnhCác lớp
Huấn luyện1,281,1671,000
Validation50,0001,000

Ảnh được lưu trong các thư mục riêng cho từng lớp, đặt tên theo ID synset WordNet (ví dụ: n01440764), đúng với cấu trúc mà quy trình huấn luyện phân loại của Ultralytics yêu cầu. Mỗi trong số 1.000 lớp ánh xạ tới một synset WordNet; không có tập kiểm tra riêng, vì vậy tập validation gồm 50.000 ảnh được dùng để đo độ chính xác.

Dung lượng tải xuống

ImageNet-1k cần tải xuống khoảng ~144 GB, vì vậy hãy đảm bảo bạn có đủ dung lượng ổ đĩa trước khi huấn luyện. Để thử nghiệm nhanh, các tập con ImageNette và ImageNet10 nhỏ hơn sử dụng cùng định dạng thư mục và có thời gian huấn luyện chỉ bằng một phần nhỏ.

Cuộc thi Nhận dạng Hình ảnh Quy mô Lớn ImageNet (ILSVRC)#

Cuộc thi Nhận dạng Hình ảnh Quy mô Lớn ImageNet (ILSVRC) thường niên cho phép các nhà nghiên cứu đánh giá benchmark thuật toán trên một bộ dữ liệu quy mô lớn, tiêu chuẩn hóa với các metric đánh giá nhất quán. Cuộc thi thúc đẩy những tiến bộ lớn trong deep learning cho phân loại ảnh, phát hiện đối tượng và các tác vụ thị giác khác — nổi bật nhất là chiến thắng của AlexNet năm 2012, góp phần mở đầu kỷ nguyên deep learning hiện đại.

Ứng dụng#

Bộ dữ liệu ImageNet được sử dụng rộng rãi để huấn luyện và đánh giá các model deep learning cho phân loại ảnh, phát hiện đối tượng và định vị đối tượng. Các kiến trúc tiêu biểu như AlexNet, VGG và ResNet đều được phát triển và đánh giá benchmark trên ImageNet; trọng số được huấn luyện trước trên ImageNet vẫn là điểm khởi đầu phổ biến cho transfer learning trên các tác vụ thị giác.

Cách sử dụng#

Để huấn luyện model phân loại YOLO trên ImageNet trong 100 epoch với kích thước ảnh 224x224, hãy dùng các đoạn mã bên dưới.

Ví dụ huấn luyện
from ultralytics import YOLO

# Tải model
model = YOLO("yolo26n-cls.pt")  # tải model đã huấn luyện trước (được khuyến nghị khi huấn luyện)

# Huấn luyện model
results = model.train(data="imagenet", epochs=100, imgsz=224)

Bạn cũng có thể quản lý bộ dữ liệu phân loại và chạy huấn luyện trên cloud bằng Ultralytics Platform.

Hình ảnh mẫu và annotation#

Bộ dữ liệu ImageNet bao gồm 1.000 lớp ILSVRC-2012, cung cấp một tài nguyên đa dạng và phong phú để huấn luyện và đánh giá các model thị giác máy tính. Dưới đây là một số ảnh mẫu từ bộ dữ liệu:

Ảnh mẫu từ bộ dữ liệu phân loại ImageNet

Trích dẫn và lời cảm ơn#

Nếu sử dụng dataset ImageNet trong nghiên cứu hoặc công việc phát triển, vui lòng trích dẫn bài báo sau:

Trích dẫn
@article{ILSVRC15,
         author = {Olga Russakovsky and Jia Deng and Hao Su and Jonathan Krause and Sanjeev Satheesh and Sean Ma and Zhiheng Huang and Andrej Karpathy and Aditya Khosla and Michael Bernstein and Alexander C. Berg and Li Fei-Fei},
         title={ImageNet Large Scale Visual Recognition Challenge},
         year={2015},
         journal={International Journal of Computer Vision (IJCV)},
         volume={115},
         number={3},
         pages={211-252}
}

Chúng tôi xin ghi nhận công lao của nhóm ImageNet, do Olga Russakovsky, Jia Deng và Li Fei-Fei dẫn dắt, trong việc tạo và duy trì bộ dữ liệu ImageNet như một tài nguyên giá trị cho cộng đồng nghiên cứu machine learning và thị giác máy tính. Để biết thêm thông tin về bộ dữ liệu ImageNet và những người tạo ra bộ dữ liệu, hãy truy cập trang web ImageNet.

Câu hỏi thường gặp#

  • Bộ dữ liệu ImageNet là cơ sở dữ liệu ảnh quy mô lớn; bộ sưu tập mở rộng của bộ dữ liệu này có hơn 14 triệu ảnh độ phân giải cao được gán nhãn bằng các synset WordNet. Trong Ultralytics, data="imagenet" huấn luyện trên tập con ILSVRC-2012 tiêu chuẩn gồm 1.000 lớp, benchmark mặc định cho tiền huấn luyện phân loại ảnh. Các model mang tính bước ngoặt như AlexNet, VGG và ResNet được huấn luyện và đánh giá benchmark trên ImageNet, cho thấy vai trò của bộ dữ liệu này trong việc thúc đẩy thị giác máy tính.

  • Bộ dữ liệu Ultralytics imagenet sử dụng tập con ILSVRC-2012 gồm 1.000 lớp, 1.281.167 ảnh huấn luyện và 50.000 ảnh validation, thường được huấn luyện ở kích thước ảnh 224x224, với tổng dung lượng tải xuống khoảng 144 GB. Cơ sở dữ liệu ImageNet đầy đủ lớn hơn nhiều (hơn 14 triệu ảnh thuộc hơn 20.000 synset WordNet), nhưng tập con 1.000 lớp là tập được dùng để huấn luyện và đánh giá benchmark phân loại.

  • Để huấn luyện model Ultralytics YOLO trên ImageNet, hãy tải một model phân loại đã được huấn luyện trước và trỏ data đến imagenet:

    Ví dụ huấn luyện
    from ultralytics import YOLO
    
    # Tải model
    model = YOLO("yolo26n-cls.pt")  # tải model đã huấn luyện trước (được khuyến nghị khi huấn luyện)
    
    # Huấn luyện model
    results = model.train(data="imagenet", epochs=100, imgsz=224)

    Để xem hướng dẫn huấn luyện chi tiết hơn, hãy tham khảo trang Huấn luyện của chúng tôi.

  • Các model phân loại pretrained Ultralytics YOLO26 mang lại sự cân bằng tốt giữa tốc độ và độ chính xác. Ví dụ, model YOLO26n-cls có độ chính xác top-1 là 71.4% và top-5 là 90.1%, được tối ưu cho các ứng dụng thời gian thực. Các model pretrained giúp giảm tài nguyên tính toán cần thiết so với huấn luyện từ đầu và rút ngắn chu kỳ phát triển.

  • Cuộc thi Nhận dạng Hình ảnh Quy mô Lớn ImageNet (ILSVRC) thường niên thúc đẩy tiến bộ trong thị giác máy tính bằng cách cung cấp một nền tảng cạnh tranh để đánh giá thuật toán trên bộ dữ liệu quy mô lớn, tiêu chuẩn hóa. Các metric đánh giá nhất quán của cuộc thi thúc đẩy đổi mới trong phân loại ảnh, phát hiện đối tượng và phân đoạn ảnh, liên tục mở rộng giới hạn của deep learning và thị giác máy tính.

Bình luận8

Đặt câu hỏi, chia sẻ kết quả hoặc giúp đỡ người khác.

    1. Paula DerrengerUltralytics(đã chỉnh sửa)

      @keeper-jie hi there!

      To reproduce the pretrained classification results on ImageNet, train from the model YAML (not the .pt weights) so the model starts from random initialization:

      Using Python:
      from ultralytics import YOLO
      
      # Build a model from its YAML configuration (replace 'yolo26n-cls.yaml' with other sizes like 'yolo26s-cls.yaml')
      model = YOLO("yolo26n-cls.yaml")
      
      # Train the model on ImageNet
      results = model.train(data="imagenet", epochs=100, imgsz=224)
      Using CLI:
      yolo train data=imagenet model=yolo26n-cls.yaml epochs=100 imgsz=224

      These commands train on the ImageNet dataset for 100 epochs at 224x224. You can adjust the epochs and imgsz parameters as needed. For more details, refer to the Ultralytics documentation on ImageNet.

      If you encounter any issues, please ensure you are using the latest version of the Ultralytics package, and provide a minimum reproducible example. Happy training! 🚀

    2. Jie Liu

      please show me the command to use yolov8 yaml file to reproduce the table result like below without pretrain model:

      Model	size(pixels)	acc-top1	acc-top5	Speed-CPU ONNX(ms)	Speed-A100 TensorRT(ms)	params(M)	FLOPs(B) at 640
      YOLOv8n-cls	224	69.0	88.3	12.9	0.31	2.7	4.3
    3. Paula DerrengerUltralytics(đã chỉnh sửa)

      Hi @keeper-jie,

      To reproduce the results of the YOLO26 classification models on the ImageNet dataset without using pretrained weights, you can follow the steps below. This will allow you to train the models from scratch and evaluate their performance.

      Using Python:
      from ultralytics import YOLO
      
      # Load a model configuration without pretrained weights
      model = YOLO("yolo26n-cls.yaml")  # You can replace 'yolo26n-cls.yaml' with other model variants like 'yolo26s-cls.yaml', 'yolo26m-cls.yaml', etc.
      
      # Train the model on ImageNet
      results = model.train(data="imagenet", epochs=100, imgsz=224)
      Using CLI:
      # Start training from scratch using a *.yaml model configuration
      yolo train data=imagenet model=yolo26n-cls.yaml epochs=100 imgsz=224

      These commands will initiate training on the ImageNet dataset for 100 epochs with an image size of 224x224 pixels. You can adjust the epochs and imgsz parameters as needed.

      Important Notes:
      • Ensure you have the latest version of the Ultralytics package installed.
      • Providing a minimum reproducible example can be very helpful if you encounter any issues. You can find more information on how to create one here.

      For more detailed information and additional arguments you can use, please refer to the Ultralytics documentation on ImageNet.

      If you have any further questions or run into any issues, feel free to ask. Happy training! 🚀

    4. Jie Liu

      I train the model with !yolo train data=/dataset/imagenet model=yolov8x-cls.yaml epochs=100 imgsz=224 batch=476*8 device=0,1,2,3,4,5,6,7, but the result is only 0.631 on top1 acc, please help me check it. Log:

      100 epochs completed in 7.923 hours.
      Optimizer stripped from /usr/src/ultralytics/runs/classify/train4/weights/last.pt, 115.1MB
      Optimizer stripped from /usr/src/ultralytics/runs/classify/train4/weights/best.pt, 115.1MB
      
      Validating /usr/src/ultralytics/runs/classify/train4/weights/best.pt...
      Ultralytics YOLOv8.1.8 🚀 Python-3.10.13 torch-2.1.0 CUDA:0 (NVIDIA L20, 45596MiB)
      YOLOv8x-cls summary (fused): 133 layers, 57404200 parameters, 0 gradients, 154.8 GFLOPs
      train: /dataset/imagenet/train... found 1281167 images in 1000 classes ✅ 
      val: /dataset/imagenet/val... found 50000 images in 1000 classes ✅ 
      test: None...
                     classes   top1_acc   top5_acc: 100%|██████████| 53/53 [00:31<00:0
                         all      0.631      0.858
    5. Paula DerrengerUltralytics(đã chỉnh sửa)

      Hi @keeper-jie,

      Thank you for sharing the details of your training process and results. To better assist you, it would be helpful to have a minimum reproducible example. This will allow us to diagnose the issue more effectively. You can find guidelines on how to create one here: Minimum Reproducible Example.

      In the meantime, here are a few suggestions to help troubleshoot and potentially improve your model's performance:

      1. Verify Dataset Integrity: Ensure that the ImageNet dataset is correctly formatted and all images are accessible. Sometimes, missing or corrupted images can affect training results.

      2. Hyperparameter Tuning: Experiment with different hyperparameters such as learning rate, batch size, and optimizer settings. The default settings might not always yield the best results for every dataset.

      3. Data Augmentation: Implementing data augmentation techniques can help improve model generalization. Techniques like random cropping, flipping, and color jittering can be beneficial.

      4. Learning Rate Scheduler: Using a learning rate scheduler can help in adjusting the learning rate during training, which might improve convergence.

      5. Regularization Techniques: Techniques such as dropout and weight decay can help in preventing overfitting and improving model performance.

      6. Latest Version: Ensure you are using the latest version of the Ultralytics package. Sometimes, updates include performance improvements and bug fixes.

      Here is an example command to train the model from scratch using the YOLO26 YAML configuration:

      Using Python:
      from ultralytics import YOLO
      
      # Load a model configuration without pretrained weights
      model = YOLO("yolo26x-cls.yaml")
      
      # Train the model on ImageNet
      results = model.train(data="imagenet", epochs=100, imgsz=224)
      Using CLI:
      # Start training from scratch using a *.yaml model configuration
      yolo train data=imagenet model=yolo26x-cls.yaml epochs=100 imgsz=224

      If the issue persists, please provide more details or a reproducible example, and we will be happy to assist you further. Thank you for your patience and cooperation!

    6. Jie Liu

      Bug description:

      use 8 L20 GPU can not reproduce yolov8x-cls top1 acc.

      MRE:

      yolo train data=imagenet model=yolov8x-cls.yaml epochs=100 imgsz=224 batch=476*8 device=0,1,2,3,4,5,6,7

      Result :

      100 epochs completed in 7.923 hours.
      Optimizer stripped from /usr/src/ultralytics/runs/classify/train4/weights/last.pt, 115.1MB
      Optimizer stripped from /usr/src/ultralytics/runs/classify/train4/weights/best.pt, 115.1MB
      
      Validating /usr/src/ultralytics/runs/classify/train4/weights/best.pt...
      Ultralytics YOLOv8.1.8 🚀 Python-3.10.13 torch-2.1.0 CUDA:0 (NVIDIA L20, 45596MiB)
      YOLOv8x-cls summary (fused): 133 layers, 57404200 parameters, 0 gradients, 154.8 GFLOPs
      train: /dataset/imagenet/train... found 1281167 images in 1000 classes ✅ 
      val: /dataset/imagenet/val... found 50000 images in 1000 classes ✅ 
      test: None...
                     classes   top1_acc   top5_acc: 100%|██████████| 53/53 [00:31<00:0
                         all      0.631      0.858

      Dependencies(yolo checks):

      Ultralytics YOLOv8.1.8 🚀 Python-3.10.13 torch-2.1.0 CUDA:0 (NVIDIA L20, 45596MiB)
      Setup complete ✅ (128 CPUs, 503.5 GB RAM, 860.1/7096.0 GB disk)
      
      OS                  Linux-5.15.0-94-generic-x86_64-with-glibc2.31
      Environment         Linux
      Python              3.10.13
      Install             git
      RAM                 503.52 GB
      CPU                 Intel Xeon Gold 6458Q
      CUDA                12.1
      
      matplotlib          ✅ 3.8.2>=3.3.0
      numpy               ✅ 1.23.5>=1.22.2
      opencv-python       ✅ 4.9.0.80>=4.6.0
      pillow              ✅ 10.0.1>=7.1.2
      pyyaml              ✅ 6.0>=5.3.1
      requests            ✅ 2.31.0>=2.23.0
      scipy               ✅ 1.12.0>=1.4.1
      torch               ✅ 2.1.0>=1.8.0
      torchvision         ✅ 0.16.0>=0.9.0
      tqdm                ✅ 4.65.0>=4.64.0
      psutil              ✅ 5.9.0
      py-cpuinfo          ✅ 9.0.0
      thop                ✅ 0.1.1-2209072238>=0.1.1
      pandas              ✅ 2.2.0>=1.1.4
      seaborn             ✅ 0.13.2>=0.11.0

      Addition train config:

      task: classify
      mode: train
      model: yolov8x-cls.yaml
      data: /dataset/imagenet
      epochs: 100
      time: null
      patience: 50
      batch: 3808
      imgsz: 224
      save: true
      save_period: -1
      cache: false
      device:
      - 0
      - 1
      - 2
      - 3
      - 4
      - 5
      - 6
      - 7
      workers: 8
      project: null
      name: train4
      exist_ok: false
      pretrained: true
      optimizer: auto
      verbose: true
      seed: 0
      deterministic: true
      single_cls: false
      rect: false
      cos_lr: false
      close_mosaic: 10
      resume: false
      amp: true
      fraction: 1.0
      profile: false
      freeze: null
      multi_scale: false
      overlap_mask: true
      mask_ratio: 4
      dropout: 0.0
      val: true
      split: val
      save_json: false
      save_hybrid: false
      conf: null
      iou: 0.7
      max_det: 300
      half: false
      dnn: false
      plots: true
      source: null
      vid_stride: 1
      stream_buffer: false
      visualize: false
      augment: false
      agnostic_nms: false
      classes: null
      retina_masks: false
      embed: null
      show: false
      save_frames: false
      save_txt: false
      save_conf: false
      save_crop: false
      show_labels: true
      show_conf: true
      show_boxes: true
      line_width: null
      format: torchscript
      keras: false
      optimize: false
      int8: false
      dynamic: false
      simplify: false
      opset: null
      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
      auto_augment: randaugment
      erasing: 0.4
      crop_fraction: 1.0
      cfg: null
      tracker: botsort.yaml
      save_dir: /usr/src/ultralytics/runs/classify/train4

      I use yolov8 docker with command docker pull ultralytics/ultralytics:8.1.8

    7. Paula DerrengerUltralytics(đã chỉnh sửa)

      Hi @keeper-jie,

      Thank you for providing detailed information about your training process and results. It's great to see that you're using the YOLOv8 classification model on the ImageNet dataset. Let's work together to troubleshoot and improve your model's performance.

      Steps to Troubleshoot and Improve Performance:
      1. Verify Dataset Integrity: Ensure that the ImageNet dataset is correctly formatted and all images are accessible. Sometimes, missing or corrupted images can affect training results.

      2. Hyperparameter Tuning: Experiment with different hyperparameters such as learning rate, batch size, and optimizer settings. The default settings might not always yield the best results for every dataset.

      3. Data Augmentation: Implementing data augmentation techniques can help improve model generalization. Techniques like random cropping, flipping, and color jittering can be beneficial.

      4. Learning Rate Scheduler: Using a learning rate scheduler can help in adjusting the learning rate during training, which might improve convergence.

      5. Regularization Techniques: Techniques such as dropout and weight decay can help in preventing overfitting and improving model performance.

      6. Latest Version: Ensure you are using the latest version of the Ultralytics package. Sometimes, updates include performance improvements and bug fixes.

      Example Command to Train from Scratch:

      Here is an example command to train the model from scratch using the YOLO26 YAML configuration:

      Using Python:
      from ultralytics import YOLO
      
      # Load a model configuration without pretrained weights
      model = YOLO("yolo26x-cls.yaml")
      
      # Train the model on ImageNet
      results = model.train(data="imagenet", epochs=100, imgsz=224)
      Using CLI:
      # Start training from scratch using a *.yaml model configuration
      yolo train data=imagenet model=yolo26x-cls.yaml epochs=100 imgsz=224
      Additional Tips:
      • Check for Overfitting: Monitor the training and validation loss. If the training loss is significantly lower than the validation loss, your model might be overfitting.
      • Use Mixed Precision Training: Enabling Automatic Mixed Precision (AMP) can speed up training and reduce memory usage.
      Minimum Reproducible Example:

      If the issue persists, please provide a minimum reproducible example. This will help us diagnose the issue more effectively. You can find guidelines on how to create one here: Minimum Reproducible Example.

      If you have any further questions or run into any issues, feel free to ask. Happy training! 🚀