WKO_PROJEKT/yolov5/classify/tutorial.ipynb
2023-02-01 23:02:19 +01:00

101 KiB
Vendored
Raw Permalink Blame History


Run on Gradient Open In Colab Open In Kaggle

This YOLOv5 🚀 notebook by Ultralytics presents simple train, validate and predict examples to help start your AI adventure.
See GitHub for community support or contact us for professional support.

Setup

Clone GitHub repository, install dependencies and check PyTorch and GPU.

!git clone https://github.com/ultralytics/yolov5  # clone
%cd yolov5
%pip install -qr requirements.txt  # install

import torch
import utils
display = utils.notebook_init()  # checks
YOLOv5 🚀 v7.0-3-g61ebf5e Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)
Setup complete ✅ (2 CPUs, 12.7 GB RAM, 22.6/78.2 GB disk)

1. Predict

classify/predict.py runs YOLOv5 Classifcation inference on a variety of sources, downloading models automatically from the latest YOLOv5 release, and saving results to runs/predict-cls. Example inference sources are:

python classify/predict.py --source 0  # webcam
                              img.jpg  # image 
                              vid.mp4  # video
                              screen  # screenshot
                              path/  # directory
                              'path/*.jpg'  # glob
                              'https://youtu.be/Zgi9g1ksQHc'  # YouTube
                              'rtsp://example.com/media.mp4'  # RTSP, RTMP, HTTP stream
!python classify/predict.py --weights yolov5s-cls.pt --img 224 --source data/images
# display.Image(filename='runs/predict-cls/exp/zidane.jpg', width=600)
classify/predict: weights=['yolov5s-cls.pt'], source=data/images, data=data/coco128.yaml, imgsz=[224, 224], device=, view_img=False, save_txt=False, nosave=False, augment=False, visualize=False, update=False, project=runs/predict-cls, name=exp, exist_ok=False, half=False, dnn=False, vid_stride=1
YOLOv5 🚀 v7.0-3-g61ebf5e Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)

Downloading https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5s-cls.pt to yolov5s-cls.pt...
100% 10.5M/10.5M [00:00<00:00, 12.3MB/s]

Fusing layers... 
Model summary: 117 layers, 5447688 parameters, 0 gradients, 11.4 GFLOPs
image 1/2 /content/yolov5/data/images/bus.jpg: 224x224 minibus 0.39, police van 0.24, amphibious vehicle 0.05, recreational vehicle 0.04, trolleybus 0.03, 3.9ms
image 2/2 /content/yolov5/data/images/zidane.jpg: 224x224 suit 0.38, bow tie 0.19, bridegroom 0.18, rugby ball 0.04, stage 0.02, 4.6ms
Speed: 0.3ms pre-process, 4.3ms inference, 1.5ms NMS per image at shape (1, 3, 224, 224)
Results saved to runs/predict-cls/exp

        

2. Validate

Validate a model's accuracy on the Imagenet dataset's val or test splits. Models are downloaded automatically from the latest YOLOv5 release. To show results by class use the --verbose flag.

# Download Imagenet val (6.3G, 50000 images)
!bash data/scripts/get_imagenet.sh --val
--2022-11-22 19:53:40--  https://image-net.org/data/ILSVRC/2012/ILSVRC2012_img_val.tar
Resolving image-net.org (image-net.org)... 171.64.68.16
Connecting to image-net.org (image-net.org)|171.64.68.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6744924160 (6.3G) [application/x-tar]
Saving to: ILSVRC2012_img_val.tar

ILSVRC2012_img_val. 100%[===================>]   6.28G  16.1MB/s    in 10m 52s 

2022-11-22 20:04:32 (9.87 MB/s) - ILSVRC2012_img_val.tar saved [6744924160/6744924160]

# Validate YOLOv5s on Imagenet val
!python classify/val.py --weights yolov5s-cls.pt --data ../datasets/imagenet --img 224 --half
classify/val: data=../datasets/imagenet, weights=['yolov5s-cls.pt'], batch_size=128, imgsz=224, device=, workers=8, verbose=True, project=runs/val-cls, name=exp, exist_ok=False, half=True, dnn=False
YOLOv5 🚀 v7.0-3-g61ebf5e Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)

Fusing layers... 
Model summary: 117 layers, 5447688 parameters, 0 gradients, 11.4 GFLOPs
validating: 100% 391/391 [04:57<00:00,  1.31it/s]
                   Class      Images    top1_acc    top5_acc
                     all       50000       0.715       0.902
                   tench          50        0.94        0.98
                goldfish          50        0.88        0.92
       great white shark          50        0.78        0.96
             tiger shark          50        0.68        0.96
        hammerhead shark          50        0.82        0.92
            electric ray          50        0.76         0.9
                stingray          50         0.7         0.9
                    cock          50        0.78        0.92
                     hen          50        0.84        0.96
                 ostrich          50        0.98           1
               brambling          50         0.9        0.96
               goldfinch          50        0.92        0.98
             house finch          50        0.88        0.96
                   junco          50        0.94        0.98
          indigo bunting          50        0.86        0.88
          American robin          50         0.9        0.96
                  bulbul          50        0.84        0.96
                     jay          50         0.9        0.96
                  magpie          50        0.84        0.96
               chickadee          50         0.9           1
         American dipper          50        0.82        0.92
                    kite          50        0.76        0.94
              bald eagle          50        0.92           1
                 vulture          50        0.96           1
          great grey owl          50        0.94        0.98
         fire salamander          50        0.96        0.98
             smooth newt          50        0.58        0.94
                    newt          50        0.74         0.9
      spotted salamander          50        0.86        0.94
                 axolotl          50        0.86        0.96
       American bullfrog          50        0.78        0.92
               tree frog          50        0.84        0.96
             tailed frog          50        0.48         0.8
   loggerhead sea turtle          50        0.68        0.94
  leatherback sea turtle          50         0.5         0.8
              mud turtle          50        0.64        0.84
                terrapin          50        0.52        0.98
              box turtle          50        0.84        0.98
            banded gecko          50         0.7        0.88
            green iguana          50        0.76        0.94
          Carolina anole          50        0.58        0.96
desert grassland whiptail lizard          50        0.82        0.94
                   agama          50        0.74        0.92
   frilled-necked lizard          50        0.84        0.86
        alligator lizard          50        0.58        0.78
            Gila monster          50        0.72         0.8
   European green lizard          50        0.42         0.9
               chameleon          50        0.76        0.84
           Komodo dragon          50        0.86        0.96
          Nile crocodile          50         0.7        0.84
      American alligator          50        0.76        0.96
             triceratops          50         0.9        0.94
              worm snake          50        0.76        0.88
       ring-necked snake          50         0.8        0.92
 eastern hog-nosed snake          50        0.58        0.88
      smooth green snake          50         0.6        0.94
               kingsnake          50        0.82         0.9
            garter snake          50        0.88        0.94
             water snake          50         0.7        0.94
              vine snake          50        0.66        0.76
             night snake          50        0.34        0.82
         boa constrictor          50         0.8        0.96
     African rock python          50        0.48        0.76
            Indian cobra          50        0.82        0.94
             green mamba          50        0.54        0.86
               sea snake          50        0.62         0.9
    Saharan horned viper          50        0.56        0.86
eastern diamondback rattlesnake          50         0.6        0.86
              sidewinder          50        0.28        0.86
               trilobite          50        0.98        0.98
              harvestman          50        0.86        0.94
                scorpion          50        0.86        0.94
    yellow garden spider          50        0.92        0.96
             barn spider          50        0.38        0.98
  European garden spider          50        0.62        0.98
    southern black widow          50        0.88        0.94
               tarantula          50        0.94           1
             wolf spider          50        0.82        0.92
                    tick          50        0.74        0.84
               centipede          50        0.68        0.82
            black grouse          50        0.88        0.98
               ptarmigan          50        0.78        0.94
           ruffed grouse          50        0.88           1
          prairie grouse          50        0.92           1
                 peacock          50        0.88         0.9
                   quail          50         0.9        0.94
               partridge          50        0.74        0.96
             grey parrot          50         0.9        0.96
                   macaw          50        0.88        0.98
sulphur-crested cockatoo          50        0.86        0.92
                lorikeet          50        0.96           1
                  coucal          50        0.82        0.88
               bee eater          50        0.96        0.98
                hornbill          50         0.9        0.96
             hummingbird          50        0.88        0.96
                 jacamar          50        0.92        0.94
                  toucan          50        0.84        0.94
                    duck          50        0.76        0.94
  red-breasted merganser          50        0.86        0.96
                   goose          50        0.74        0.96
              black swan          50        0.94        0.98
                  tusker          50        0.54        0.92
                 echidna          50        0.98           1
                platypus          50        0.72        0.84
                 wallaby          50        0.78        0.88
                   koala          50        0.84        0.92
                  wombat          50        0.78        0.84
               jellyfish          50        0.88        0.96
             sea anemone          50        0.72         0.9
             brain coral          50        0.88        0.96
                flatworm          50         0.8        0.98
                nematode          50        0.86         0.9
                   conch          50        0.74        0.88
                   snail          50        0.78        0.88
                    slug          50        0.74        0.82
                sea slug          50        0.88        0.98
                  chiton          50        0.88        0.98
      chambered nautilus          50        0.88        0.92
          Dungeness crab          50        0.78        0.94
               rock crab          50        0.68        0.86
            fiddler crab          50        0.64        0.86
           red king crab          50        0.76        0.96
        American lobster          50        0.78        0.96
           spiny lobster          50        0.74        0.88
                crayfish          50        0.56        0.86
             hermit crab          50        0.78        0.96
                  isopod          50        0.66        0.78
             white stork          50        0.88        0.96
             black stork          50        0.84        0.98
               spoonbill          50        0.96           1
                flamingo          50        0.94           1
       little blue heron          50        0.92        0.98
             great egret          50         0.9        0.96
                 bittern          50        0.86        0.94
            crane (bird)          50        0.62         0.9
                 limpkin          50        0.98           1
        common gallinule          50        0.92        0.96
           American coot          50         0.9        0.98
                 bustard          50        0.92        0.96
         ruddy turnstone          50        0.94           1
                  dunlin          50        0.86        0.94
         common redshank          50         0.9        0.96
               dowitcher          50        0.84        0.96
           oystercatcher          50        0.86        0.94
                 pelican          50        0.92        0.96
            king penguin          50        0.88        0.96
               albatross          50         0.9           1
              grey whale          50        0.84        0.92
            killer whale          50        0.92           1
                  dugong          50        0.84        0.96
                sea lion          50        0.82        0.92
               Chihuahua          50        0.66        0.84
           Japanese Chin          50        0.72        0.98
                 Maltese          50        0.76        0.94
               Pekingese          50        0.84        0.94
                Shih Tzu          50        0.74        0.96
    King Charles Spaniel          50        0.88        0.98
                Papillon          50        0.86        0.94
             toy terrier          50        0.48        0.94
     Rhodesian Ridgeback          50        0.76        0.98
            Afghan Hound          50        0.84           1
            Basset Hound          50         0.8        0.92
                  Beagle          50        0.82        0.96
              Bloodhound          50        0.48        0.72
      Bluetick Coonhound          50        0.86        0.94
 Black and Tan Coonhound          50        0.54         0.8
Treeing Walker Coonhound          50        0.66        0.98
        English foxhound          50        0.32        0.84
       Redbone Coonhound          50        0.62        0.94
                  borzoi          50        0.92           1
         Irish Wolfhound          50        0.48        0.88
       Italian Greyhound          50        0.76        0.98
                 Whippet          50        0.74        0.92
            Ibizan Hound          50         0.6        0.86
      Norwegian Elkhound          50        0.88        0.98
              Otterhound          50        0.62         0.9
                  Saluki          50        0.72        0.92
      Scottish Deerhound          50        0.86        0.98
              Weimaraner          50        0.88        0.94
Staffordshire Bull Terrier          50        0.66        0.98
American Staffordshire Terrier          50        0.64        0.92
      Bedlington Terrier          50         0.9        0.92
          Border Terrier          50        0.86        0.92
      Kerry Blue Terrier          50        0.78        0.98
           Irish Terrier          50         0.7        0.96
         Norfolk Terrier          50        0.68         0.9
         Norwich Terrier          50        0.72           1
       Yorkshire Terrier          50        0.66         0.9
        Wire Fox Terrier          50        0.64        0.98
        Lakeland Terrier          50        0.74        0.92
        Sealyham Terrier          50        0.76         0.9
        Airedale Terrier          50        0.82        0.92
           Cairn Terrier          50        0.76         0.9
      Australian Terrier          50        0.48        0.84
  Dandie Dinmont Terrier          50        0.82        0.92
          Boston Terrier          50        0.92           1
     Miniature Schnauzer          50        0.68         0.9
         Giant Schnauzer          50        0.72        0.98
      Standard Schnauzer          50        0.74           1
        Scottish Terrier          50        0.76        0.96
         Tibetan Terrier          50        0.48           1
Australian Silky Terrier          50        0.66        0.96
Soft-coated Wheaten Terrier          50        0.74        0.96
West Highland White Terrier          50        0.88        0.96
              Lhasa Apso          50        0.68        0.96
   Flat-Coated Retriever          50        0.72        0.94
  Curly-coated Retriever          50        0.82        0.94
        Golden Retriever          50        0.86        0.94
      Labrador Retriever          50        0.82        0.94
Chesapeake Bay Retriever          50        0.76        0.96
German Shorthaired Pointer          50         0.8        0.96
                  Vizsla          50        0.68        0.96
          English Setter          50         0.7           1
            Irish Setter          50         0.8         0.9
           Gordon Setter          50        0.84        0.92
                Brittany          50        0.84        0.96
         Clumber Spaniel          50        0.92        0.96
English Springer Spaniel          50        0.88           1
  Welsh Springer Spaniel          50        0.92           1
         Cocker Spaniels          50         0.7        0.94
          Sussex Spaniel          50        0.72        0.92
     Irish Water Spaniel          50        0.88        0.98
                  Kuvasz          50        0.66         0.9
              Schipperke          50         0.9        0.98
             Groenendael          50         0.8        0.94
                Malinois          50        0.86        0.98
                  Briard          50        0.52         0.8
       Australian Kelpie          50         0.6        0.88
                Komondor          50        0.88        0.94
    Old English Sheepdog          50        0.94        0.98
       Shetland Sheepdog          50        0.74         0.9
                  collie          50         0.6        0.96
           Border Collie          50        0.74        0.96
    Bouvier des Flandres          50        0.78        0.94
              Rottweiler          50        0.88        0.96
     German Shepherd Dog          50         0.8        0.98
               Dobermann          50        0.68        0.96
      Miniature Pinscher          50        0.76        0.88
Greater Swiss Mountain Dog          50        0.68        0.94
    Bernese Mountain Dog          50        0.96           1
  Appenzeller Sennenhund          50        0.22           1
  Entlebucher Sennenhund          50        0.64        0.98
                   Boxer          50         0.7        0.92
             Bullmastiff          50        0.78        0.98
         Tibetan Mastiff          50        0.88        0.96
          French Bulldog          50        0.84        0.94
              Great Dane          50        0.54         0.9
             St. Bernard          50        0.92           1
                   husky          50        0.46        0.98
        Alaskan Malamute          50        0.76        0.96
          Siberian Husky          50        0.46        0.98
               Dalmatian          50        0.94        0.98
           Affenpinscher          50        0.78         0.9
                 Basenji          50        0.92        0.94
                     pug          50        0.94        0.98
              Leonberger          50           1           1
            Newfoundland          50        0.78        0.96
   Pyrenean Mountain Dog          50        0.78        0.96
                 Samoyed          50        0.96           1
              Pomeranian          50        0.98           1
               Chow Chow          50         0.9        0.96
                Keeshond          50        0.88        0.94
      Griffon Bruxellois          50        0.84        0.98
    Pembroke Welsh Corgi          50        0.82        0.94
    Cardigan Welsh Corgi          50        0.66        0.98
              Toy Poodle          50        0.52        0.88
        Miniature Poodle          50        0.52        0.92
         Standard Poodle          50         0.8           1
    Mexican hairless dog          50        0.88        0.98
               grey wolf          50        0.82        0.92
     Alaskan tundra wolf          50        0.78        0.98
                red wolf          50        0.48         0.9
                  coyote          50        0.64        0.86
                   dingo          50        0.76        0.88
                   dhole          50         0.9        0.98
        African wild dog          50        0.98           1
                   hyena          50        0.88        0.96
                 red fox          50        0.54        0.92
                 kit fox          50        0.72        0.98
              Arctic fox          50        0.94           1
                grey fox          50         0.7        0.94
               tabby cat          50        0.54        0.92
               tiger cat          50        0.22        0.94
             Persian cat          50         0.9        0.98
             Siamese cat          50        0.96           1
            Egyptian Mau          50        0.54         0.8
                  cougar          50         0.9           1
                    lynx          50        0.72        0.88
                 leopard          50        0.78        0.98
            snow leopard          50         0.9        0.98
                  jaguar          50         0.7        0.94
                    lion          50         0.9        0.98
                   tiger          50        0.92        0.98
                 cheetah          50        0.94        0.98
              brown bear          50        0.94        0.98
     American black bear          50         0.8           1
              polar bear          50        0.84        0.96
              sloth bear          50        0.72        0.92
                mongoose          50         0.7        0.92
                 meerkat          50        0.82        0.92
            tiger beetle          50        0.92        0.94
                 ladybug          50        0.86        0.94
           ground beetle          50        0.64        0.94
         longhorn beetle          50        0.62        0.88
             leaf beetle          50        0.64        0.98
             dung beetle          50        0.86        0.98
       rhinoceros beetle          50        0.86        0.94
                  weevil          50         0.9           1
                     fly          50        0.78        0.94
                     bee          50        0.68        0.94
                     ant          50        0.68        0.78
             grasshopper          50         0.5        0.92
                 cricket          50        0.64        0.92
            stick insect          50        0.64        0.92
               cockroach          50        0.72         0.8
                  mantis          50        0.64        0.86
                  cicada          50         0.9        0.96
              leafhopper          50        0.88        0.94
                lacewing          50        0.78        0.92
               dragonfly          50        0.82        0.98
               damselfly          50        0.82           1
             red admiral          50        0.94        0.96
                 ringlet          50        0.86        0.98
       monarch butterfly          50         0.9        0.92
             small white          50         0.9           1
       sulphur butterfly          50        0.92           1
gossamer-winged butterfly          50        0.88           1
                starfish          50        0.88        0.92
              sea urchin          50        0.84        0.94
            sea cucumber          50        0.66        0.84
       cottontail rabbit          50        0.72        0.94
                    hare          50        0.84        0.96
           Angora rabbit          50        0.94        0.98
                 hamster          50        0.96           1
               porcupine          50        0.88        0.98
            fox squirrel          50        0.76        0.94
                  marmot          50        0.92        0.96
                  beaver          50        0.78        0.94
              guinea pig          50        0.78        0.94
           common sorrel          50        0.96        0.98
                   zebra          50        0.94        0.96
                     pig          50         0.5        0.76
               wild boar          50        0.84        0.96
                 warthog          50        0.84        0.96
            hippopotamus          50        0.88        0.96
                      ox          50        0.48        0.94
           water buffalo          50        0.78        0.94
                   bison          50        0.88        0.96
                     ram          50        0.58        0.92
           bighorn sheep          50        0.66           1
             Alpine ibex          50        0.92        0.98
              hartebeest          50        0.94           1
                  impala          50        0.82        0.96
                 gazelle          50         0.7        0.96
               dromedary          50         0.9           1
                   llama          50        0.82        0.94
                  weasel          50        0.44        0.92
                    mink          50        0.78        0.96
        European polecat          50        0.46         0.9
     black-footed ferret          50        0.68        0.96
                   otter          50        0.66        0.88
                   skunk          50        0.96        0.96
                  badger          50        0.86        0.92
               armadillo          50        0.88         0.9
        three-toed sloth          50        0.96           1
               orangutan          50        0.78        0.92
                 gorilla          50        0.82        0.94
              chimpanzee          50        0.84        0.94
                  gibbon          50        0.76        0.86
                 siamang          50        0.68        0.94
                  guenon          50         0.8        0.94
            patas monkey          50        0.62        0.82
                  baboon          50         0.9        0.98
                 macaque          50         0.8        0.86
                  langur          50         0.6        0.82
 black-and-white colobus          50        0.86         0.9
        proboscis monkey          50           1           1
                marmoset          50        0.74        0.98
   white-headed capuchin          50        0.72         0.9
           howler monkey          50        0.86        0.94
                    titi          50         0.5         0.9
Geoffroy's spider monkey          50        0.42         0.8
  common squirrel monkey          50        0.76        0.92
       ring-tailed lemur          50        0.72        0.94
                   indri          50         0.9        0.96
          Asian elephant          50        0.58        0.92
   African bush elephant          50         0.7        0.98
               red panda          50        0.94        0.94
             giant panda          50        0.94        0.98
                   snoek          50        0.74         0.9
                     eel          50         0.6        0.84
             coho salmon          50        0.84        0.96
             rock beauty          50        0.88        0.98
               clownfish          50        0.78        0.98
                sturgeon          50        0.68        0.94
                 garfish          50        0.62         0.8
                lionfish          50        0.96        0.96
              pufferfish          50        0.88        0.96
                  abacus          50        0.74        0.88
                   abaya          50        0.84        0.92
           academic gown          50        0.42        0.86
               accordion          50         0.8         0.9
         acoustic guitar          50         0.5        0.76
        aircraft carrier          50         0.8        0.96
                airliner          50        0.92           1
                 airship          50        0.76        0.82
                   altar          50        0.64        0.98
               ambulance          50        0.88        0.98
      amphibious vehicle          50        0.64        0.94
            analog clock          50        0.52        0.92
                  apiary          50        0.82        0.96
                   apron          50         0.7        0.84
         waste container          50         0.4         0.8
           assault rifle          50        0.42        0.84
                backpack          50        0.34        0.64
                  bakery          50         0.4        0.68
            balance beam          50         0.8        0.98
                 balloon          50        0.86        0.96
           ballpoint pen          50        0.52        0.96
                Band-Aid          50         0.7         0.9
                   banjo          50        0.84           1
                baluster          50        0.68        0.94
                 barbell          50        0.56         0.9
            barber chair          50         0.7        0.92
              barbershop          50        0.54        0.86
                    barn          50        0.96        0.96
               barometer          50        0.84        0.98
                  barrel          50        0.56        0.88
             wheelbarrow          50        0.66        0.88
                baseball          50        0.74        0.98
              basketball          50        0.88        0.98
                bassinet          50        0.66        0.92
                 bassoon          50        0.74        0.98
            swimming cap          50        0.62        0.88
              bath towel          50        0.54        0.78
                 bathtub          50         0.4        0.88
           station wagon          50        0.66        0.84
              lighthouse          50        0.78        0.94
                  beaker          50        0.52        0.68
            military cap          50        0.84        0.96
             beer bottle          50        0.66        0.88
              beer glass          50         0.6        0.84
                bell-cot          50        0.56        0.96
                     bib          50        0.58        0.82
          tandem bicycle          50        0.86        0.96
                  bikini          50        0.56        0.88
             ring binder          50        0.64        0.84
              binoculars          50        0.54        0.78
               birdhouse          50        0.86        0.94
               boathouse          50        0.74        0.92
               bobsleigh          50        0.92        0.96
                bolo tie          50         0.8        0.94
             poke bonnet          50        0.64        0.86
                bookcase          50        0.66        0.92
               bookstore          50        0.62        0.88
              bottle cap          50        0.58         0.7
                     bow          50        0.72        0.86
                 bow tie          50         0.7         0.9
                   brass          50        0.92        0.96
                     bra          50         0.5         0.7
              breakwater          50        0.62        0.86
             breastplate          50         0.4         0.9
                   broom          50         0.6        0.86
                  bucket          50        0.66         0.8
                  buckle          50         0.5        0.68
        bulletproof vest          50         0.5        0.78
        high-speed train          50        0.94        0.96
            butcher shop          50        0.74        0.94
                 taxicab          50        0.64        0.86
                cauldron          50        0.44        0.66
                  candle          50        0.48        0.74
                  cannon          50        0.88        0.94
                   canoe          50        0.94           1
              can opener          50        0.66        0.86
                cardigan          50        0.68         0.8
              car mirror          50        0.94        0.96
                carousel          50        0.94        0.98
                tool kit          50        0.56        0.78
                  carton          50        0.42         0.7
               car wheel          50        0.38        0.74
automated teller machine          50        0.76        0.94
                cassette          50        0.52         0.8
         cassette player          50        0.28         0.9
                  castle          50        0.78        0.88
               catamaran          50        0.78           1
               CD player          50        0.52        0.82
                   cello          50        0.82           1
            mobile phone          50        0.68        0.86
                   chain          50        0.38        0.66
        chain-link fence          50         0.7        0.84
              chain mail          50        0.64         0.9
                chainsaw          50        0.84        0.92
                   chest          50        0.68        0.92
              chiffonier          50        0.26        0.64
                   chime          50        0.62        0.84
           china cabinet          50        0.82        0.96
      Christmas stocking          50        0.92        0.94
                  church          50        0.62         0.9
           movie theater          50        0.58        0.88
                 cleaver          50        0.32        0.62
          cliff dwelling          50        0.88           1
                   cloak          50        0.32        0.64
                   clogs          50        0.58        0.88
         cocktail shaker          50        0.62         0.7
              coffee mug          50        0.44        0.72
             coffeemaker          50        0.64        0.92
                    coil          50        0.66        0.84
        combination lock          50        0.64        0.84
       computer keyboard          50         0.7        0.82
     confectionery store          50        0.54        0.86
          container ship          50        0.82        0.98
             convertible          50        0.78        0.98
               corkscrew          50        0.82        0.92
                  cornet          50        0.46        0.88
             cowboy boot          50        0.64         0.8
              cowboy hat          50        0.64        0.82
                  cradle          50        0.38         0.8
         crane (machine)          50        0.78        0.94
            crash helmet          50        0.92        0.96
                   crate          50        0.52        0.82
              infant bed          50        0.74           1
               Crock Pot          50        0.78         0.9
            croquet ball          50         0.9        0.96
                  crutch          50        0.46         0.7
                 cuirass          50        0.54        0.86
                     dam          50        0.74        0.92
                    desk          50         0.6        0.86
        desktop computer          50        0.54        0.94
   rotary dial telephone          50        0.88        0.94
                  diaper          50        0.68        0.84
           digital clock          50        0.54        0.76
           digital watch          50        0.58        0.86
            dining table          50        0.76         0.9
               dishcloth          50        0.94           1
              dishwasher          50        0.44        0.78
              disc brake          50        0.98           1
                    dock          50        0.54        0.94
                dog sled          50        0.84           1
                    dome          50        0.72        0.92
                 doormat          50        0.56        0.82
            drilling rig          50        0.84        0.96
                    drum          50        0.38        0.68
               drumstick          50        0.56        0.72
                dumbbell          50        0.62         0.9
              Dutch oven          50         0.7        0.84
            electric fan          50        0.82        0.86
         electric guitar          50        0.62        0.84
     electric locomotive          50        0.92        0.98
    entertainment center          50         0.9        0.98
                envelope          50        0.44        0.86
        espresso machine          50        0.72        0.94
             face powder          50         0.7        0.92
             feather boa          50         0.7        0.84
          filing cabinet          50        0.88        0.98
                fireboat          50        0.94        0.98
             fire engine          50        0.84         0.9
       fire screen sheet          50        0.62        0.76
                flagpole          50        0.74        0.88
                   flute          50        0.36        0.72
           folding chair          50        0.62        0.84
         football helmet          50        0.86        0.94
                forklift          50         0.8        0.92
                fountain          50        0.84        0.94
            fountain pen          50        0.76        0.92
         four-poster bed          50        0.78        0.94
             freight car          50        0.96           1
             French horn          50        0.76        0.92
              frying pan          50        0.36        0.78
                fur coat          50        0.84        0.96
           garbage truck          50         0.9        0.98
                gas mask          50        0.84        0.92
                gas pump          50         0.9        0.98
                  goblet          50        0.68        0.82
                 go-kart          50         0.9           1
               golf ball          50        0.84         0.9
               golf cart          50        0.78        0.86
                 gondola          50        0.98        0.98
                    gong          50        0.74        0.92
                    gown          50        0.62        0.96
             grand piano          50         0.7        0.96
              greenhouse          50         0.8        0.98
                  grille          50        0.72         0.9
           grocery store          50        0.66        0.94
              guillotine          50        0.86        0.92
                barrette          50        0.52        0.66
              hair spray          50         0.5        0.74
              half-track          50        0.78         0.9
                  hammer          50        0.56        0.76
                  hamper          50        0.64        0.84
              hair dryer          50        0.56        0.74
      hand-held computer          50        0.42        0.86
            handkerchief          50        0.78        0.94
         hard disk drive          50        0.76        0.84
               harmonica          50         0.7        0.88
                    harp          50        0.88        0.96
               harvester          50        0.78           1
                 hatchet          50        0.54        0.74
                 holster          50        0.66        0.84
            home theater          50        0.64        0.94
               honeycomb          50        0.56        0.88
                    hook          50         0.3         0.6
              hoop skirt          50        0.64        0.86
          horizontal bar          50        0.68        0.98
     horse-drawn vehicle          50        0.88        0.94
               hourglass          50        0.88        0.96
                    iPod          50        0.76        0.94
            clothes iron          50        0.82        0.88
         jack-o'-lantern          50        0.98        0.98
                   jeans          50        0.68        0.84
                    jeep          50        0.72         0.9
                 T-shirt          50        0.72        0.96
           jigsaw puzzle          50        0.84        0.94
         pulled rickshaw          50        0.86        0.94
                joystick          50         0.8         0.9
                  kimono          50        0.84        0.96
                knee pad          50        0.62        0.88
                    knot          50        0.66         0.8
                lab coat          50         0.8        0.96
                   ladle          50        0.36        0.64
               lampshade          50        0.48        0.84
         laptop computer          50        0.26        0.88
              lawn mower          50        0.78        0.96
                lens cap          50        0.46        0.72
             paper knife          50        0.26         0.5
                 library          50        0.54         0.9
                lifeboat          50        0.92        0.98
                 lighter          50        0.56        0.78
               limousine          50        0.76        0.92
             ocean liner          50        0.88        0.94
                lipstick          50        0.74         0.9
            slip-on shoe          50        0.74        0.92
                  lotion          50         0.5        0.86
                 speaker          50        0.52        0.68
                   loupe          50        0.32        0.52
                 sawmill          50        0.72         0.9
        magnetic compass          50        0.52        0.82
                mail bag          50        0.68        0.92
                 mailbox          50        0.82        0.92
                  tights          50        0.22        0.94
               tank suit          50        0.24         0.9
           manhole cover          50        0.96        0.98
                  maraca          50        0.74         0.9
                 marimba          50        0.84        0.94
                    mask          50        0.44        0.82
                   match          50        0.66         0.9
                 maypole          50        0.96           1
                    maze          50         0.8        0.96
           measuring cup          50        0.54        0.76
          medicine chest          50         0.6        0.84
                megalith          50         0.8        0.92
              microphone          50        0.52         0.7
          microwave oven          50        0.48        0.72
        military uniform          50        0.62        0.84
                milk can          50        0.68        0.82
                 minibus          50         0.7           1
               miniskirt          50        0.46        0.76
                 minivan          50        0.38         0.8
                 missile          50         0.4        0.84
                  mitten          50        0.76        0.88
             mixing bowl          50         0.8        0.92
             mobile home          50        0.54        0.78
                 Model T          50        0.92        0.96
                   modem          50        0.58        0.86
               monastery          50        0.44         0.9
                 monitor          50         0.4        0.86
                   moped          50        0.56        0.94
                  mortar          50        0.68        0.94
     square academic cap          50         0.5        0.84
                  mosque          50         0.9           1
            mosquito net          50         0.9        0.98
                 scooter          50         0.9        0.98
           mountain bike          50        0.78        0.96
                    tent          50        0.88        0.96
          computer mouse          50        0.42        0.82
               mousetrap          50        0.76        0.88
              moving van          50         0.4        0.72
                  muzzle          50         0.5        0.72
                    nail          50        0.68        0.74
              neck brace          50        0.56        0.68
                necklace          50        0.86           1
                  nipple          50         0.7        0.88
       notebook computer          50        0.34        0.84
                 obelisk          50         0.8        0.92
                    oboe          50         0.6        0.84
                 ocarina          50         0.8        0.86
                odometer          50        0.96           1
              oil filter          50        0.58        0.82
                   organ          50        0.82         0.9
            oscilloscope          50         0.9        0.96
               overskirt          50         0.2         0.7
            bullock cart          50         0.7        0.94
             oxygen mask          50        0.46        0.84
                  packet          50         0.5        0.78
                  paddle          50        0.56        0.94
            paddle wheel          50        0.86        0.96
                 padlock          50        0.74        0.78
              paintbrush          50        0.62         0.8
                 pajamas          50        0.56        0.92
                  palace          50        0.64        0.96
               pan flute          50        0.84        0.86
             paper towel          50        0.66        0.84
               parachute          50        0.92        0.94
           parallel bars          50        0.62        0.96
              park bench          50        0.74         0.9
           parking meter          50        0.84        0.92
           passenger car          50         0.5        0.82
                   patio          50        0.58        0.84
                payphone          50        0.74        0.92
                pedestal          50        0.52         0.9
             pencil case          50        0.64        0.92
        pencil sharpener          50        0.52        0.78
                 perfume          50         0.7         0.9
              Petri dish          50         0.6         0.8
             photocopier          50        0.88        0.98
                plectrum          50         0.7        0.84
             Pickelhaube          50        0.72        0.86
            picket fence          50        0.84        0.94
            pickup truck          50        0.64        0.92
                    pier          50        0.52        0.82
              piggy bank          50        0.82        0.94
             pill bottle          50        0.76        0.86
                  pillow          50        0.76         0.9
          ping-pong ball          50        0.84        0.88
                pinwheel          50        0.76        0.88
             pirate ship          50        0.76        0.94
                 pitcher          50        0.46        0.84
              hand plane          50        0.84        0.94
             planetarium          50        0.88        0.98
             plastic bag          50        0.36        0.62
              plate rack          50        0.52        0.78
                    plow          50        0.78        0.88
                 plunger          50        0.42         0.7
         Polaroid camera          50        0.84        0.92
                    pole          50        0.38        0.74
              police van          50        0.76        0.94
                  poncho          50        0.58        0.86
          billiard table          50         0.8        0.88
             soda bottle          50        0.56        0.94
                     pot          50        0.78        0.92
          potter's wheel          50         0.9        0.94
             power drill          50        0.42        0.72
              prayer rug          50         0.7        0.86
                 printer          50        0.54        0.86
                  prison          50         0.7         0.9
              projectile          50        0.28         0.9
               projector          50        0.62        0.84
             hockey puck          50        0.92        0.96
            punching bag          50         0.6        0.68
                   purse          50        0.42        0.78
                   quill          50        0.68        0.84
                   quilt          50        0.64         0.9
                race car          50        0.72        0.92
                  racket          50        0.72         0.9
                radiator          50        0.66        0.76
                   radio          50        0.64        0.92
         radio telescope          50         0.9        0.96
             rain barrel          50         0.8        0.98
    recreational vehicle          50        0.84        0.94
                    reel          50        0.72        0.82
           reflex camera          50        0.72        0.92
            refrigerator          50         0.7         0.9
          remote control          50         0.7        0.88
              restaurant          50         0.5        0.66
                revolver          50        0.82           1
                   rifle          50        0.38         0.7
           rocking chair          50        0.62        0.84
              rotisserie          50        0.88        0.92
                  eraser          50        0.54        0.76
              rugby ball          50        0.86        0.94
                   ruler          50        0.68        0.86
            running shoe          50        0.78        0.94
                    safe          50        0.82        0.92
              safety pin          50         0.4        0.62
             salt shaker          50        0.66         0.9
                  sandal          50        0.66        0.86
                  sarong          50        0.64        0.86
               saxophone          50        0.66        0.88
                scabbard          50        0.76        0.92
          weighing scale          50        0.58        0.78
              school bus          50        0.92           1
                schooner          50        0.84           1
              scoreboard          50         0.9        0.96
              CRT screen          50        0.14         0.7
                   screw          50         0.9        0.98
             screwdriver          50         0.3        0.58
               seat belt          50        0.88        0.94
          sewing machine          50        0.76         0.9
                  shield          50        0.56        0.82
              shoe store          50        0.78        0.96
                   shoji          50         0.8        0.92
         shopping basket          50        0.52        0.88
           shopping cart          50        0.76        0.92
                  shovel          50        0.62        0.84
              shower cap          50         0.7        0.84
          shower curtain          50        0.64        0.82
                     ski          50        0.74        0.92
                ski mask          50        0.72        0.88
            sleeping bag          50        0.68         0.8
              slide rule          50        0.72        0.88
            sliding door          50        0.44        0.78
            slot machine          50        0.94        0.98
                 snorkel          50        0.86        0.98
              snowmobile          50        0.88           1
                snowplow          50        0.84        0.98
          soap dispenser          50        0.56        0.86
             soccer ball          50        0.86        0.96
                    sock          50        0.62        0.76
 solar thermal collector          50        0.72        0.96
                sombrero          50         0.6        0.84
               soup bowl          50        0.56        0.94
               space bar          50        0.34        0.88
            space heater          50        0.52        0.74
           space shuttle          50        0.82        0.96
                 spatula          50         0.3         0.6
               motorboat          50        0.86           1
              spider web          50         0.7         0.9
                 spindle          50        0.86        0.98
              sports car          50         0.6        0.94
               spotlight          50        0.26         0.6
                   stage          50        0.68        0.86
        steam locomotive          50        0.94           1
     through arch bridge          50        0.84        0.96
              steel drum          50        0.82         0.9
             stethoscope          50         0.6        0.82
                   scarf          50         0.5        0.92
              stone wall          50        0.76         0.9
               stopwatch          50        0.58         0.9
                   stove          50        0.46        0.74
                strainer          50        0.64        0.84
                    tram          50        0.88        0.96
               stretcher          50         0.6         0.8
                   couch          50         0.8        0.96
                   stupa          50        0.88        0.88
               submarine          50        0.72        0.92
                    suit          50         0.4        0.78
                 sundial          50        0.58        0.74
                sunglass          50        0.14        0.58
              sunglasses          50        0.28        0.58
               sunscreen          50        0.32         0.7
       suspension bridge          50         0.6        0.94
                     mop          50        0.74        0.92
              sweatshirt          50        0.28        0.66
                swimsuit          50        0.52        0.82
                   swing          50        0.76        0.84
                  switch          50        0.56        0.76
                 syringe          50        0.62        0.82
              table lamp          50         0.6        0.88
                    tank          50         0.8        0.96
             tape player          50        0.46        0.76
                  teapot          50        0.84           1
              teddy bear          50        0.82        0.94
              television          50         0.6         0.9
             tennis ball          50         0.7        0.94
           thatched roof          50        0.88         0.9
           front curtain          50         0.8        0.92
                 thimble          50         0.6         0.8
       threshing machine          50        0.56        0.88
                  throne          50        0.72        0.82
               tile roof          50        0.72        0.94
                 toaster          50        0.66        0.84
            tobacco shop          50        0.42         0.7
             toilet seat          50        0.62        0.88
                   torch          50        0.64        0.84
              totem pole          50        0.92        0.98
               tow truck          50        0.62        0.88
               toy store          50         0.6        0.94
                 tractor          50        0.76        0.98
      semi-trailer truck          50        0.78        0.92
                    tray          50        0.46        0.64
             trench coat          50        0.54        0.72
                tricycle          50        0.72        0.94
                trimaran          50         0.7        0.98
                  tripod          50        0.58        0.86
          triumphal arch          50        0.92        0.98
              trolleybus          50         0.9           1
                trombone          50        0.54        0.88
                     tub          50        0.24        0.82
               turnstile          50        0.84        0.94
     typewriter keyboard          50        0.68        0.98
                umbrella          50        0.52         0.7
                unicycle          50        0.74        0.96
           upright piano          50        0.76         0.9
          vacuum cleaner          50        0.62         0.9
                    vase          50         0.5        0.78
                   vault          50        0.76        0.92
                  velvet          50         0.2        0.42
         vending machine          50         0.9           1
                vestment          50        0.54        0.82
                 viaduct          50        0.78        0.86
                  violin          50        0.68        0.78
              volleyball          50        0.86           1
             waffle iron          50        0.72        0.88
              wall clock          50        0.54        0.88
                  wallet          50        0.52         0.9
                wardrobe          50        0.68        0.88
       military aircraft          50         0.9        0.98
                    sink          50        0.72        0.96
         washing machine          50        0.78        0.94
            water bottle          50        0.54        0.74
               water jug          50        0.22        0.74
             water tower          50         0.9        0.96
             whiskey jug          50        0.64        0.74
                 whistle          50        0.72        0.84
                     wig          50        0.84         0.9
           window screen          50        0.68         0.8
            window shade          50        0.52        0.76
             Windsor tie          50        0.22        0.66
             wine bottle          50        0.42        0.82
                    wing          50        0.54        0.96
                     wok          50        0.46        0.82
            wooden spoon          50        0.58         0.8
                    wool          50        0.32        0.82
        split-rail fence          50        0.74         0.9
               shipwreck          50        0.84        0.96
                    yawl          50        0.78        0.96
                    yurt          50        0.84           1
                 website          50        0.98           1
              comic book          50        0.62         0.9
               crossword          50        0.84        0.88
            traffic sign          50        0.78         0.9
           traffic light          50         0.8        0.94
             dust jacket          50        0.72        0.94
                    menu          50        0.82        0.96
                   plate          50        0.44        0.88
               guacamole          50         0.8        0.92
                consomme          50        0.54        0.88
                 hot pot          50        0.86        0.98
                  trifle          50        0.92        0.98
               ice cream          50        0.68        0.94
                 ice pop          50        0.62        0.84
                baguette          50        0.62        0.88
                   bagel          50        0.64        0.92
                 pretzel          50        0.72        0.88
            cheeseburger          50         0.9           1
                 hot dog          50        0.74        0.94
           mashed potato          50        0.74         0.9
                 cabbage          50        0.84        0.96
                broccoli          50         0.9        0.96
             cauliflower          50        0.82           1
                zucchini          50        0.74         0.9
        spaghetti squash          50         0.8        0.96
            acorn squash          50        0.82        0.96
        butternut squash          50         0.7        0.94
                cucumber          50         0.6        0.96
               artichoke          50        0.84        0.94
             bell pepper          50        0.84        0.98
                 cardoon          50        0.88        0.94
                mushroom          50        0.38        0.92
            Granny Smith          50         0.9        0.96
              strawberry          50         0.6        0.88
                  orange          50         0.7        0.92
                   lemon          50        0.78        0.98
                     fig          50        0.82        0.96
               pineapple          50        0.86        0.96
                  banana          50        0.84        0.96
               jackfruit          50         0.9        0.98
           custard apple          50        0.86        0.96
             pomegranate          50        0.82        0.98
                     hay          50         0.8        0.92
               carbonara          50        0.88        0.94
         chocolate syrup          50        0.46        0.84
                   dough          50         0.4         0.6
                meatloaf          50        0.58        0.84
                   pizza          50        0.84        0.96
                 pot pie          50        0.68         0.9
                 burrito          50         0.8        0.98
                red wine          50        0.54        0.82
                espresso          50        0.64        0.88
                     cup          50        0.38         0.7
                  eggnog          50        0.38         0.7
                     alp          50        0.54        0.88
                  bubble          50         0.8        0.96
                   cliff          50        0.64           1
              coral reef          50        0.72        0.96
                  geyser          50        0.94           1
               lakeshore          50        0.54        0.88
              promontory          50        0.58        0.94
                   shoal          50         0.6        0.96
                seashore          50        0.44        0.78
                  valley          50        0.72        0.94
                 volcano          50        0.78        0.96
         baseball player          50        0.72        0.94
              bridegroom          50        0.72        0.88
             scuba diver          50         0.8           1
                rapeseed          50        0.94        0.98
                   daisy          50        0.96        0.98
   yellow lady's slipper          50           1           1
                    corn          50         0.4        0.88
                   acorn          50        0.92        0.98
                rose hip          50        0.92        0.98
     horse chestnut seed          50        0.94        0.98
            coral fungus          50        0.96        0.96
                  agaric          50        0.82        0.94
               gyromitra          50        0.98           1
      stinkhorn mushroom          50         0.8        0.94
              earth star          50        0.98           1
        hen-of-the-woods          50         0.8        0.96
                  bolete          50        0.74        0.94
                     ear          50        0.48        0.94
            toilet paper          50        0.36        0.68
Speed: 0.1ms pre-process, 0.3ms inference, 0.0ms post-process per image at shape (1, 3, 224, 224)
Results saved to runs/val-cls/exp

3. Train

Close the active learning loop by sampling images from your inference conditions with the `roboflow` pip package

Train a YOLOv5s Classification model on the Imagenette dataset with --data imagenet, starting from pretrained --pretrained yolov5s-cls.pt.

  • Pretrained Models are downloaded automatically from the latest YOLOv5 release
  • Training Results are saved to runs/train-cls/ with incrementing run directories, i.e. runs/train-cls/exp2, runs/train-cls/exp3 etc.

A Mosaic Dataloader is used for training which combines 4 images into 1 mosaic.

Train on Custom Data with Roboflow 🌟 NEW

Roboflow enables you to easily organize, label, and prepare a high quality dataset with your own custom data. Roboflow also makes it easy to establish an active learning pipeline, collaborate with your team on dataset improvement, and integrate directly into your model building workflow with the roboflow pip package.

Label images lightning fast (including with model-assisted labeling)
#@title Select YOLOv5 🚀 logger {run: 'auto'}
logger = 'TensorBoard' #@param ['TensorBoard', 'Comet', 'ClearML']

if logger == 'TensorBoard':
  %load_ext tensorboard
  %tensorboard --logdir runs/train
elif logger == 'Comet':
  %pip install -q comet_ml
  import comet_ml; comet_ml.init()
elif logger == 'ClearML':
  import clearml; clearml.browser_login()
# Train YOLOv5s Classification on Imagenette160 for 3 epochs
!python classify/train.py --model yolov5s-cls.pt --data imagenette160 --epochs 5 --img 224 --cache
classify/train: model=yolov5s-cls.pt, data=imagenette160, epochs=5, batch_size=64, imgsz=224, nosave=False, cache=ram, device=, workers=8, project=runs/train-cls, name=exp, exist_ok=False, pretrained=True, optimizer=Adam, lr0=0.001, decay=5e-05, label_smoothing=0.1, cutoff=None, dropout=None, verbose=False, seed=0, local_rank=-1
github: up to date with https://github.com/ultralytics/yolov5 ✅
YOLOv5 🚀 v7.0-3-g61ebf5e Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)

TensorBoard: Start with 'tensorboard --logdir runs/train-cls', view at http://localhost:6006/

Dataset not found ⚠️, missing path /content/datasets/imagenette160, attempting download...
Downloading https://github.com/ultralytics/yolov5/releases/download/v1.0/imagenette160.zip to /content/datasets/imagenette160.zip...
100% 103M/103M [00:00<00:00, 347MB/s] 
Unzipping /content/datasets/imagenette160.zip...
Dataset download success ✅ (3.3s), saved to /content/datasets/imagenette160

albumentations: RandomResizedCrop(p=1.0, height=224, width=224, scale=(0.08, 1.0), ratio=(0.75, 1.3333333333333333), interpolation=1), HorizontalFlip(p=0.5), ColorJitter(p=0.5, brightness=[0.6, 1.4], contrast=[0.6, 1.4], saturation=[0.6, 1.4], hue=[0, 0]), Normalize(p=1.0, mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), max_pixel_value=255.0), ToTensorV2(always_apply=True, p=1.0, transpose_mask=False)
Model summary: 149 layers, 4185290 parameters, 4185290 gradients, 10.5 GFLOPs
optimizer: Adam(lr=0.001) with parameter groups 32 weight(decay=0.0), 33 weight(decay=5e-05), 33 bias
Image sizes 224 train, 224 test
Using 1 dataloader workers
Logging results to runs/train-cls/exp
Starting yolov5s-cls.pt training on imagenette160 dataset with 10 classes for 5 epochs...

     Epoch   GPU_mem  train_loss    val_loss    top1_acc    top5_acc
       1/5     1.47G        1.05       0.974       0.828       0.975: 100% 148/148 [00:38<00:00,  3.82it/s]
       2/5     1.73G       0.895       0.766       0.911       0.994: 100% 148/148 [00:36<00:00,  4.03it/s]
       3/5     1.73G        0.82       0.704       0.934       0.996: 100% 148/148 [00:35<00:00,  4.20it/s]
       4/5     1.73G       0.766       0.664       0.951       0.998: 100% 148/148 [00:36<00:00,  4.05it/s]
       5/5     1.73G       0.724       0.634       0.959       0.997: 100% 148/148 [00:37<00:00,  3.94it/s]

Training complete (0.052 hours)
Results saved to runs/train-cls/exp
Predict:         python classify/predict.py --weights runs/train-cls/exp/weights/best.pt --source im.jpg
Validate:        python classify/val.py --weights runs/train-cls/exp/weights/best.pt --data /content/datasets/imagenette160
Export:          python export.py --weights runs/train-cls/exp/weights/best.pt --include onnx
PyTorch Hub:     model = torch.hub.load('ultralytics/yolov5', 'custom', 'runs/train-cls/exp/weights/best.pt')
Visualize:       https://netron.app

4. Visualize

Comet Logging and Visualization 🌟 NEW

Comet is now fully integrated with YOLOv5. Track and visualize model metrics in real time, save your hyperparameters, datasets, and model checkpoints, and visualize your model predictions with Comet Custom Panels! Comet makes sure you never lose track of your work and makes it easy to share results and collaborate across teams of all sizes!

Getting started is easy:

pip install comet_ml  # 1. install
export COMET_API_KEY=<Your API Key>  # 2. paste API key
python train.py --img 640 --epochs 3 --data coco128.yaml --weights yolov5s.pt  # 3. train

To learn more about all of the supported Comet features for this integration, check out the Comet Tutorial. If you'd like to learn more about Comet, head over to our documentation. Get started by trying out the Comet Colab Notebook: Open In Colab

Comet Dashboard

ClearML Logging and Automation 🌟 NEW

ClearML is completely integrated into YOLOv5 to track your experimentation, manage dataset versions and even remotely execute training runs. To enable ClearML (check cells above):

You'll get all the great expected features from an experiment manager: live updates, model upload, experiment comparison etc. but ClearML also tracks uncommitted changes and installed packages for example. Thanks to that ClearML Tasks (which is what we call experiments) are also reproducible on different machines! With only 1 extra line, we can schedule a YOLOv5 training task on a queue to be executed by any number of ClearML Agents (workers).

You can use ClearML Data to version your dataset and then pass it to YOLOv5 simply using its unique ID. This will help you keep track of your data without adding extra hassle. Explore the ClearML Tutorial for details!

ClearML Experiment Management UI

Local Logging

Training results are automatically logged with Tensorboard and CSV loggers to runs/train, with a new experiment directory created for each new training as runs/train/exp2, runs/train/exp3, etc.

This directory contains train and val statistics, mosaics, labels, predictions and augmentated mosaics, as well as metrics and charts including precision-recall (PR) curves and confusion matrices.

Local logging results

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit.

Appendix

Additional content below.

# YOLOv5 PyTorch HUB Inference (DetectionModels only)
import torch

model = torch.hub.load('ultralytics/yolov5', 'yolov5s')  # yolov5n - yolov5x6 or custom
im = 'https://ultralytics.com/images/zidane.jpg'  # file, Path, PIL.Image, OpenCV, nparray, list
results = model(im)  # inference
results.print()  # or .show(), .save(), .crop(), .pandas(), etc.