• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Learn OpenCV

OpenCV, PyTorch, Keras, Tensorflow examples and tutorials

  • Home
  • Getting Started
    • Installation
    • PyTorch
    • Keras & Tensorflow
    • Resource Guide
  • Courses
    • Opencv Courses
    • CV4Faces (Old)
  • Resources
  • AI Consulting
  • About

Fast Image Downloader for Open Images V4

Sunita Nayak
February 4, 2019 Leave a Comment
Deep Learning how-to Image Classification Image Recognition Machine Learning Object Detection Tutorial Uncategorized

February 4, 2019 By Leave a Comment

Last year, Google released a publicly available dataset called Open Images V4 which contains 15.4M annotated bounding boxes for over 600 object categories. It has 1.9M images and is largest among all existing datasets with object location annotations. The classes include a variety of objects in various categories. It covers classes varying from different kinds of musical instruments(e.g. organ, cello, piano etc.) to different kinds of aquatic animals(e.g. goldfish, crab, seahorse, oyster etc.) to various kinds of kitchenware(e.g. spoon, kitchen knife, frying pan, dishwasher) and so on. Below we show some classes of outdoor items.

Example of open images classes

All existing classes in Open Images can be seen as a dendrogram here.

The dataset can speed up many computer vision tasks by days or even months. For example, if we want to make an object detector for a single or multiple objects, we could download the images of those classes only along with their annotations and start our training process. In this post, we provide you a script that helps you download the images using multithreading, which can make the download process more than 10 times faster. It also generates the annotation files with the bounding box information for the objects instances in the images.

We present a table below which lists the number of train, validation and test instances for each class. You can also search for any objects of your interest in the table to see if there are enough number of instances to start your training.

Class NameTrainValidationTest
Clothing1438128852726531
Man1418594565417514
Tree1051344320910148
Human face1037710517015536
Person10347211327440861
Woman76733728659047
Footwear744474718921205
Window50346716505091
Flower345296508915040
Wheel3406391139434604
Plant267913380811579
Car248075938128737
Human hair234057859426301
Human arm208982834125162
Human head201633786525080
Girl19715524207479
Building1786349842915
Human body175244676920246
Mammal156154434913479
House136152246822
Chair1324835111535
Tire122615418113177
Suit110848321857
Fashion accessory9102410263164
Food8842227368331
Boy875556002031
Table856917142279
Skyscraper8126157232
Land vehicle8110826898480
Boat791139032672
Jeans784733961433
Human eye77233430413034
Human hand75307412312505
Human leg71479409313334
Toy709634371205
Tower6794582264
Human nose60142434112718
Bicycle wheel595217332018
Glasses57946262890
Dress529995671581
Vehicle5095921057064
Bird479219432751
Sports equipment44900395111992
Street light4469722242
Human mouth4419725057424
Palm tree42026253620
Book412806982147
Tableware41086285936
Drink403234821427
Bottle40188340979
Bicycle401614031158
Furniture385276461893
Snack373747082173
Sculpture34533221653
Flag2924687252
Dog2867519305818
Dessert274076452092
Microphone27272110272
Fruit2623619056215
Jacket25957136461
Guitar25896114357
Fast food249914921599
Drum24818109352
Sunglasses23996114390
Poster23566107346
Fish231955641422
Baked goods2301010202907
Shelf22899191563
Houseplant22834319825
Flowerpot22760302659
Airplane2128510273272
Sports uniform193963151135
Door19256165524
Vegetable186214961679
Human ear177748702611
Animal17442290882
Shorts16981134443
Musical instrument16503178525
Helmet165024401275
Bicycle helmet15952147390
Duck15451119294
Wine15400193388
Cat151833811095
Auto part1358628988845
Balloon13505117455
Motorcycle13382173530
Horse133683921144
Hat13245201557
Train1305091315
Wine glass12934119356
Truck12135311969
Rose12053309899
Picture frame1195757158
Bus1192792353
Football helmet11705130375
Desk1169348136
Cattle11603170450
Bee1140184279
Tie1054584271
Hiking equipment1050593458
Butterfly1012774265
Swimwear10079149574
Billboard98232950
Goggles9636101218
Beer9565118332
Laptop932761199
Cabinetry9191188451
Marine invertebrates911268217
Insect8981210717
Trousers8481143495
Goose843655116
Dairy8146308970
Strawberry7944326774
Vehicle registration plate78525121570
Van7720151500
Shirt746557185
Traffic light742649131
Bench722900
Umbrella72043097
Sun hat697952205
Paddle6951253699
Tent690730117
Ball6845266902
Sunflower681555124
Coat652355240
Lavender647287326
Doll644277188
Camera6404132338
Mobile phone6365137454
Tomato6254216722
Office supplies619876233
Orange6195175839
Pumpkin615049157
Traffic sign61122872
Computer monitor611257215
Stairs598137122
Candle588675134
Pastry585248170
Cake5784326878
Roller skates5476295723
Lantern54292760
Plate541667214
Box536494256
Coffee cup5327160538
Coffee table531441104
Bookcase5307100301
Watercraft5202155510
Football509764220
Office building498645103
Maple49231354
Curtain487248170
Kitchen appliance466276234
Muffin460882310
Canoe454382292
Computer keyboard454242173
Swan452349136
Bowl450751153
Mushroom4497126465
Cocktail4458148406
Drawer4414184448
Castle43101271
Couch425944104
Christmas tree42435383
Taxi419991104
Penguin419785161
Cookie4158184636
Apple3898102334
Swimming pool3881142354
Deer3867132449
Porch385433100
Bread3846277911
Bowling equipment384698339
Television378939124
Fountain36911963
Lifejacket3678103273
Lamp366370116
Fedora366051175
Bed3563114328
Beetle352347163
Pillow350861264
Ski350578431
Carnivore3501200625
Platter346283198
Sheep343889273
Elephant327256232
Human beard3157153481
Boot3132163472
High heels3124119277
Countertop311361143
Salad3088213605
Cowboy hat306824142
Seafood3063226689
Chicken305965227
Coin304293245
Monkey3026195543
Helicopter3023134424
Tin can298842188
Weapon2960155388
Sandal2938181393
Juice2838174512
Ice cream2834118395
Violin28283598
Saucer281973248
Grape2787153447
Cart275575200
Bronze sculpture274851101
Necklace273560162
Bathroom accessory267853132
Parachute2672121286
Skull26612491
Surfboard259465189
Rifle2540110315
Baseball glove25293189
Handbag249560188
Vase246856171
Cosmetics239450151
Parrot238882283
Coffee2384124353
Scarf23033368
Mug227224107
Candy2261116337
Lily2252124496
Human foot2237199467
Luggage and bags22203599
Goldfish220438129
Kitchen & dining room table212744157
Lizard212095301
French fries211475215
Sushi208874186
Home appliance208699275
Barrel208673165
Harbor seal208450157
Tool207541137
Goat207576245
Jellyfish206491133
Medical equipment206084207
Spider203363224
Pizza200895217
Cello20043885
Tortoise199853178
Squirrel19404094
Watch19032677
Aircraft1898186556
Studio couch188951141
Gondola18682574
Egg1865144576
Moths and butterflies18571641
Shrimp1856116266
Sea lion182354170
Convenience store181765171
Light bulb18163747
Skateboard181072203
Waste container180719103
Musical keyboard177146151
Kite17663075
Lemon1756171425
Marine mammal174647157
Bull1736107289
Dinosaur17212857
Falcon171737156
Tank171658161
Spoon170950162
Pen170549149
Eagle170450201
Tap169546108
Brassiere169483246
Fork168745143
Owl16633091
Lion165362142
Sparrow165163163
Sink164854119
Rabbit164162220
Pig161369201
Banana161222133
Frog160841122
Teddy bear158730125
Mirror15722184
Invertebrate1568124376
Antelope156885385
Cheese1560127323
Trumpet154646123
Dolphin153287237
Chest of drawers152687196
Lighthouse1518834
Sofa bed150155150
Dragonfly14901665
Hamburger148680206
Wheelchair1464107288
Carrot145650155
Tripod144626103
Earrings14462576
Giraffe14312573
Sock142515136
Snake137864241
Piano137482215
Cupboard135385218
Lipstick13433799
Tea134247136
Camel13403087
Shellfish128750128
Grapefruit128362344
Tiger12602157
Skirt12591561
Headphones12553597
Stool12543085
Horn123936110
Baseball bat12281948
Clock12222360
Backpack12162870
Saxophone12083797
Glove119854158
Cucumber1194100259
Sandwich115790240
Bear113750163
Sea turtle113236155
Broccoli112832182
Nightstand11252475
Zebra112044123
Mule11174197
Toilet10992861
Zucchini109850164
Cannon10872066
Crocodile106952108
Wall clock10671842
Bust10601829
Crab104166162
Oyster1038106159
Whale101442124
Mixing bowl10052565
Whiteboard10031637
Ladder9942065
Plastic bag986919
Tennis racket98521102
Barge983411
Tablet computer975937
Tart97326151
Accordion9552479
Miniskirt9542889
Trombone9531761
Snowboard9441653
Snail94339136
Doughnut93049192
Ant9252876
Pear92318111
Rocket9181388
Billiard table9122885
Caterpillar88424104
Panda8822051
Coconut8742191
Mouse85734165
Knife85077216
Table tennis racket84929110
Watermelon84432126
Alpaca82934121
Leopard81140125
Bell pepper80267219
Kangaroo7783282
Pancake77563102
Snowman770430
Pasta769118327
Peach75664280
Otter75243146
Door handle7511979
Willow73525
Turkey7342372
Ladybug7342364
Computer mouse7332484
Wok7302436
Handgun7272481
Rhinoceros7242170
Cheetah7152972
Dice71452119
Fireplace7113562
Waffle7102590
Radish6882167
Crown6871950
Hippopotamus6851354
Mechanical fan6812065
Taco67749194
Pomegranate6771262
Polar bear6643593
Volleyball66118111
Closet6611044
Pineapple66025110
Kettle6572673
Washing machine65539121
Bat655628
Sombrero651720
Brown bear6471377
Ostrich64034137
Bagel64043111
Starfish6392181
Oven6372153
Teapot6323778
Loveseat6312150
Suitcase6303079
Shark6255299
Chopsticks6171436
Swim cap61537140
Missile6032275
Potato59956128
Lobster5973095
Ipod5952961
Golf cart595832
Bow and arrow5942145
Refrigerator5922082
Jug5902376
Jaguar5863595
Shotgun5802666
Reptile5783493
Window blind5701351
Sword5672389
Raven56732107
Segway56534132
Fox5653882
Kitchen utensil54957142
Hamster54632140
Bathtub5451559
Jet ski5431832
Gas stove5261749
Scoreboard517916
Woodpecker5151440
Beehive5112757
Tennis ball502839
Nail49102
Rays and skates4852683
Microwave oven4852046
Hot dog4821248
Plumbing fixture48151125
Ceiling fan4781140
Infant bed4621862
Seat belt46138
Sewing machine4532574
Croissant4474078
Ambulance4471367
Bidet4402149
Cabbage43524101
Golf ball4341256
Corded phone433618
Fire hydrant4321457
Mango4291226
Picnic basket4251226
Red panda4231262
Belt4221332
Koala4181449
Dumbbell4131332
Tiara4111246
Personal care4091118
Scissors39916
Organ3982163
Stop sign3941333
Canary3871332
Asparagus3871953
Honeycomb3831144
Raccoon3812378
Toilet paper377311
Frying pan3771116
Artichoke3762663
Squash3752047
Filing cabinet3742482
Dagger37034101
Snowmobile366870
Limousine3663169
Perfume3631946
Popcorn3621991
Flute3621431
Bathroom cabinet358216
Kitchen knife3502983
Pitcher3471441
Towel338729
Stationary bicycle338437
Cake stand33737
Punching bag336010
Ratchet32700
Balance beam326948
Coffeemaker3231850
Common fig3172474
Seahorse3142260
Wood-burning stove3001934
Snowplow3001950
Rugby ball294728
Pretzel2942135
Drinking straw292417
Power plugs and sockets2902044
Racket2813499
Centipede2801159
Telephone2741626
Submarine sandwich2732966
Worm270219
Dog bed26638
Banjo264813
Printer2631948
Burrito26234121
Hedgehog2612283
Blue jay2592160
Adhesive tape25511
Wine rack254718
Ruler2531535
Flying disc24903
Treadmill247720
Wardrobe238842
Lynx2371348
Remote control236726
Shower235932
Blender2351030
Harp2311850
Porcupine2291787
Guacamole2242165
Squid221823
Toothbrush2191620
Mixer216940
Milk2141439
Cutting board213213
Harpsichord2121533
Paper towel21027
Calculator2101151
Parking meter20923
Cat furniture20802
Turtle205820
Wrench20413
Scorpion2041749
Drill20315
Digital clock199739
Unicycle194214
Training bench194210
Food processor192327
Whisk18001
Salt and pepper shakers18045
Envelope177412
Stretcher174613
Alarm clock1691027
Beaker16806
Cantaloupe1661629
Oboe162628
Briefcase162417
Isopod15487
Diaper15213
Crutch15002
Axe14802
Magpie1452239
Tick14301
Scale139514
Hammer13910
Pencil case13215
Cricket ball13237
Spice rack131319
Chainsaw13027
Syringe127019
Slow cooker12515
Cream1231669
Binoculars123616
Serving tray11818
Tree house110419
Jacuzzi1031628
Light switch97107
Dishwasher9223
Flashlight88623
Screwdriver8510
Ring binder8400
Submarine811021
Face powder80317
Stethoscope7819
Soap dispenser7801
Horizontal bar7569
Measuring cup7401
Cassette deck74932
Toaster7314
Hand dryer7001
Spatula6442
Stapler5901
Skunk56323
Armadillo5600
Ladle5400
Eraser5301
Cooking spray4500
Winter melon4338
Chime4101
Harmonica3805
Band-aid3600
Indoor rower3506
Heater3500
Chisel3310
Waffle iron3100
Fax2843
Hair dryer2703
Cocktail shaker2700
Pencil sharpener2100
Bottle opener2101
Torch20214
Pizza cutter2000
Facial tissue holder2000
Pressure cooker1411
Grinder1400
Humidifier1100
Maracas1000
Hair spray1000
Bomb800
Can opener700
Paper cutter400
Kitchenware000
Container000

Download data

Lets go through a step by step process of how we can download data for a selected set of classes.

Download Code To easily follow along this tutorial, please download code by clicking on the button below. It's FREE!

Download Code

Step 1:

First we will need to install awscli

sudo pip3 install awscli

Step 2:

Then we need to get the following OpenImages files

class-descriptions-boxable.csv – It contains a mapping of the class names used internally in the dataset to human interpretable names, e.g. /m/011k07 is Tortoise, /m/011q46kg is Container, /m/012074 is Magpie etc.

train-annotations-bbox.csv – It contains annotations of the object instances in the training images.

validation-annotations-bbox.csv – It contains annotations of the object instances in the validation images.

test-annotations-bbox.csv – It contains annotations of the object instances in the test images.

You could get the above images using the links above or using wget as shown below from the command line.

wget https://storage.googleapis.com/openimages/2018_04/class-descriptions-boxable.csv

wget https://storage.googleapis.com/openimages/2018_04/train/train-annotations-bbox.csv

wget https://storage.googleapis.com/openimages/2018_04/validation/validation-annotations-bbox.csv

wget https://storage.googleapis.com/openimages/2018_04/test/test-annotations-bbox.csv 
 

Step 3:

Next, move the above .csv files to the same folder as the downloaded code and then use the following script to download the data. The example below downloads all the training instances for the three classes – Cheese, Ice cream and Cookie.

python3 downloadOI.py --classes 'Cheese,Ice_cream,Cookie' --mode train
 

Similarly, to get the validation or test images, we can set the mode argument to validation or test respectively.

When you do it for your own set of classes, make sure that if there is a space in the class name, it is replaced by an underscore(‘_’). In the above example, we replaced the ‘Ice cream’ class name with ‘Ice_cream’.

You can also add optional parameters to exclude certain kind of images by setting them explicitly to 0 in the command line.

occluded=0 to exclude occluded instances.

truncated=0 to exclude instances that are truncated at the boundary.

groupOf=0 to exclude instances that represent a group of objects together. These instances usually include a group of 5 or more objects of the same class physically touching or occluding each other, e.g. a bag of apples.

depiction=0 to exclude instances that are sketches or cartoons instead of picture of a real physical object.

inside=0 to exclude instances where the picture is taken from inside the object, e.g inside a car.

By default, all the above optional parameters are set to 1. So if you do not want to include the groupOf and inside instances, but want all other instances in your training, then the download command would be:

python3 downloadOI.py --classes 'Cheese,Ice_cream,Cookie' --mode train --groupOf=0 --inside=0
 

The directory structure of the download would be as follows:

– class-descriptions-boxable.csv
– train-annotations-bbox.csv
– validation-annotations-bbox.csv
– downloadOI.py
        – train
                – ClassA
                        – .jpg files
                        – .txt files
                – ClassB
                        – .jpg files
                        – .txt files
        – validation
                – ClassA
                        – .jpg files
                        – .txt files
                – ClassB
                        – .jpg files
                        – .txt files

Become an expert in Computer Vision, Machine Learning, and AI in 12-weeks! Check out our course

Computer Vision Course

Label Files

Open Images provides the top left corner and the bottom right corner of the bounding box of each object instance. The X and Y coordinates of these points are represented as proportions to the image width and height respectively.

The script writes the labels of all instances of the same class in the same image into a single text file. This label file is placed in the same directory as the image file, as shown in the directory structure above.

Subscribe & Download Code

If you liked this article and would like to download code (C++ and Python) and example images used in this post, please subscribe to our newsletter. You will also receive a free Computer Vision Resource Guide. In our newsletter, we share OpenCV tutorials and examples written in C++/Python, and Computer Vision and Machine Learning algorithms and news.

Subscribe Now


References

  1. OpenImages: A public dataset for large-scale multi-label and multi-class image classification, 2017

    Krasin I., Duerig T., Alldrin N., Ferrari V., Abu-El-Haija S., Kuznetsova A., Rom H., Uijlings J., Popov S., Kamali S., Malloci M., Pont-Tuset J., Veit A., Belongie S., Gomes V., Gupta A., Sun C., Chechik G., Cai D., Feng Z., Narayanan D., Murphy K.

  2. The Open Images Dataset V4: Unified image classification, object detection, and visual relationship detection at scale.

    A. Kuznetsova, H. Rom, N. Alldrin, J. Uijlings, I. Krasin, J. Pont-Tuset, S. Kamali, S. Popov, M. Malloci, T. Duerig, and V. Ferrari.
    arXiv:1811.00982, 2018.

Tags: dataset deep learning download Image Classification Open Images train

Filed Under: Deep Learning, how-to, Image Classification, Image Recognition, Machine Learning, Object Detection, Tutorial, Uncategorized

About

I am an entrepreneur with a love for Computer Vision and Machine Learning with a dozen years of experience (and a Ph.D.) in the field.

In 2007, right after finishing my Ph.D., I co-founded TAAZ Inc. with my advisor Dr. David Kriegman and Kevin Barnes. The scalability, and robustness of our computer vision and machine learning algorithms have been put to rigorous test by more than 100M users who have tried our products. Read More…

Getting Started

  • Installation
  • PyTorch
  • Keras & Tensorflow
  • Resource Guide

Resources

Download Code (C++ / Python)

ENROLL IN OFFICIAL OPENCV COURSES

I've partnered with OpenCV.org to bring you official courses in Computer Vision, Machine Learning, and AI.
Learn More

Recent Posts

  • Making A Low-Cost Stereo Camera Using OpenCV
  • Optical Flow in OpenCV (C++/Python)
  • Introduction to Epipolar Geometry and Stereo Vision
  • Depth Estimation using Stereo matching
  • Classification with Localization: Convert any Keras Classifier to a Detector

Disclaimer

All views expressed on this site are my own and do not represent the opinions of OpenCV.org or any entity whatsoever with which I have been, am now, or will be affiliated.

GETTING STARTED

  • Installation
  • PyTorch
  • Keras & Tensorflow
  • Resource Guide

COURSES

  • Opencv Courses
  • CV4Faces (Old)

COPYRIGHT © 2020 - BIG VISION LLC

Privacy Policy | Terms & Conditions

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.AcceptPrivacy policy