ferdianndl007 glenn-jocher commited on
Commit
dbce1bc
1 Parent(s): 33712d6

Objects365 Dataset (#2932)

Browse files

* add object365

* ADD CONVERSION SCRIPT

* fix transcript

* Reformat and simplify

* spelling

* Update get_objects365.py

Co-authored-by: Glenn Jocher <[email protected]>

data/hyp.finetune_objects365.yaml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ lr0: 0.00258
2
+ lrf: 0.17
3
+ momentum: 0.779
4
+ weight_decay: 0.00058
5
+ warmup_epochs: 1.33
6
+ warmup_momentum: 0.86
7
+ warmup_bias_lr: 0.0711
8
+ box: 0.0539
9
+ cls: 0.299
10
+ cls_pw: 0.825
11
+ obj: 0.632
12
+ obj_pw: 1.0
13
+ iou_t: 0.2
14
+ anchor_t: 3.44
15
+ anchors: 3.2
16
+ fl_gamma: 0.0
17
+ hsv_h: 0.0188
18
+ hsv_s: 0.704
19
+ hsv_v: 0.36
20
+ degrees: 0.0
21
+ translate: 0.0902
22
+ scale: 0.491
23
+ shear: 0.0
24
+ perspective: 0.0
25
+ flipud: 0.0
26
+ fliplr: 0.5
27
+ mosaic: 1.0
28
+ mixup: 0.0
data/objects365.yaml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Objects365 dataset https://www.objects365.org/
2
+ # Train command: python train.py --data objects365.yaml
3
+ # Default dataset location is next to YOLOv5:
4
+ # /parent_folder
5
+ # /datasets/objects365
6
+ # /yolov5
7
+
8
+ # train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/]
9
+ train: ../datasets/objects365/images/train # 1.7 Million images
10
+ val: ../datasets/objects365/images/val # 5570 images
11
+
12
+ # number of classes
13
+ nc: 365
14
+
15
+ # class names
16
+ names: [ 'Person', 'Sneakers', 'Chair', 'Other Shoes', 'Hat', 'Car', 'Lamp', 'Glasses', 'Bottle', 'Desk', 'Cup',
17
+ 'Street Lights', 'Cabinet/shelf', 'Handbag/Satchel', 'Bracelet', 'Plate', 'Picture/Frame', 'Helmet', 'Book',
18
+ 'Gloves', 'Storage box', 'Boat', 'Leather Shoes', 'Flower', 'Bench', 'Potted Plant', 'Bowl/Basin', 'Flag',
19
+ 'Pillow', 'Boots', 'Vase', 'Microphone', 'Necklace', 'Ring', 'SUV', 'Wine Glass', 'Belt', 'Monitor/TV',
20
+ 'Backpack', 'Umbrella', 'Traffic Light', 'Speaker', 'Watch', 'Tie', 'Trash bin Can', 'Slippers', 'Bicycle',
21
+ 'Stool', 'Barrel/bucket', 'Van', 'Couch', 'Sandals', 'Basket', 'Drum', 'Pen/Pencil', 'Bus', 'Wild Bird',
22
+ 'High Heels', 'Motorcycle', 'Guitar', 'Carpet', 'Cell Phone', 'Bread', 'Camera', 'Canned', 'Truck',
23
+ 'Traffic cone', 'Cymbal', 'Lifesaver', 'Towel', 'Stuffed Toy', 'Candle', 'Sailboat', 'Laptop', 'Awning',
24
+ 'Bed', 'Faucet', 'Tent', 'Horse', 'Mirror', 'Power outlet', 'Sink', 'Apple', 'Air Conditioner', 'Knife',
25
+ 'Hockey Stick', 'Paddle', 'Pickup Truck', 'Fork', 'Traffic Sign', 'Balloon', 'Tripod', 'Dog', 'Spoon', 'Clock',
26
+ 'Pot', 'Cow', 'Cake', 'Dinning Table', 'Sheep', 'Hanger', 'Blackboard/Whiteboard', 'Napkin', 'Other Fish',
27
+ 'Orange/Tangerine', 'Toiletry', 'Keyboard', 'Tomato', 'Lantern', 'Machinery Vehicle', 'Fan',
28
+ 'Green Vegetables', 'Banana', 'Baseball Glove', 'Airplane', 'Mouse', 'Train', 'Pumpkin', 'Soccer', 'Skiboard',
29
+ 'Luggage', 'Nightstand', 'Tea pot', 'Telephone', 'Trolley', 'Head Phone', 'Sports Car', 'Stop Sign',
30
+ 'Dessert', 'Scooter', 'Stroller', 'Crane', 'Remote', 'Refrigerator', 'Oven', 'Lemon', 'Duck', 'Baseball Bat',
31
+ 'Surveillance Camera', 'Cat', 'Jug', 'Broccoli', 'Piano', 'Pizza', 'Elephant', 'Skateboard', 'Surfboard',
32
+ 'Gun', 'Skating and Skiing shoes', 'Gas stove', 'Donut', 'Bow Tie', 'Carrot', 'Toilet', 'Kite', 'Strawberry',
33
+ 'Other Balls', 'Shovel', 'Pepper', 'Computer Box', 'Toilet Paper', 'Cleaning Products', 'Chopsticks',
34
+ 'Microwave', 'Pigeon', 'Baseball', 'Cutting/chopping Board', 'Coffee Table', 'Side Table', 'Scissors',
35
+ 'Marker', 'Pie', 'Ladder', 'Snowboard', 'Cookies', 'Radiator', 'Fire Hydrant', 'Basketball', 'Zebra', 'Grape',
36
+ 'Giraffe', 'Potato', 'Sausage', 'Tricycle', 'Violin', 'Egg', 'Fire Extinguisher', 'Candy', 'Fire Truck',
37
+ 'Billiards', 'Converter', 'Bathtub', 'Wheelchair', 'Golf Club', 'Briefcase', 'Cucumber', 'Cigar/Cigarette',
38
+ 'Paint Brush', 'Pear', 'Heavy Truck', 'Hamburger', 'Extractor', 'Extension Cord', 'Tong', 'Tennis Racket',
39
+ 'Folder', 'American Football', 'earphone', 'Mask', 'Kettle', 'Tennis', 'Ship', 'Swing', 'Coffee Machine',
40
+ 'Slide', 'Carriage', 'Onion', 'Green beans', 'Projector', 'Frisbee', 'Washing Machine/Drying Machine',
41
+ 'Chicken', 'Printer', 'Watermelon', 'Saxophone', 'Tissue', 'Toothbrush', 'Ice cream', 'Hot-air balloon',
42
+ 'Cello', 'French Fries', 'Scale', 'Trophy', 'Cabbage', 'Hot dog', 'Blender', 'Peach', 'Rice', 'Wallet/Purse',
43
+ 'Volleyball', 'Deer', 'Goose', 'Tape', 'Tablet', 'Cosmetics', 'Trumpet', 'Pineapple', 'Golf Ball',
44
+ 'Ambulance', 'Parking meter', 'Mango', 'Key', 'Hurdle', 'Fishing Rod', 'Medal', 'Flute', 'Brush', 'Penguin',
45
+ 'Megaphone', 'Corn', 'Lettuce', 'Garlic', 'Swan', 'Helicopter', 'Green Onion', 'Sandwich', 'Nuts',
46
+ 'Speed Limit Sign', 'Induction Cooker', 'Broom', 'Trombone', 'Plum', 'Rickshaw', 'Goldfish', 'Kiwi fruit',
47
+ 'Router/modem', 'Poker Card', 'Toaster', 'Shrimp', 'Sushi', 'Cheese', 'Notepaper', 'Cherry', 'Pliers', 'CD',
48
+ 'Pasta', 'Hammer', 'Cue', 'Avocado', 'Hamimelon', 'Flask', 'Mushroom', 'Screwdriver', 'Soap', 'Recorder',
49
+ 'Bear', 'Eggplant', 'Board Eraser', 'Coconut', 'Tape Measure/Ruler', 'Pig', 'Showerhead', 'Globe', 'Chips',
50
+ 'Steak', 'Crosswalk Sign', 'Stapler', 'Camel', 'Formula 1', 'Pomegranate', 'Dishwasher', 'Crab',
51
+ 'Hoverboard', 'Meat ball', 'Rice Cooker', 'Tuba', 'Calculator', 'Papaya', 'Antelope', 'Parrot', 'Seal',
52
+ 'Butterfly', 'Dumbbell', 'Donkey', 'Lion', 'Urinal', 'Dolphin', 'Electric Drill', 'Hair Dryer', 'Egg tart',
53
+ 'Jellyfish', 'Treadmill', 'Lighter', 'Grapefruit', 'Game board', 'Mop', 'Radish', 'Baozi', 'Target', 'French',
54
+ 'Spring Rolls', 'Monkey', 'Rabbit', 'Pencil Case', 'Yak', 'Red Cabbage', 'Binoculars', 'Asparagus', 'Barbell',
55
+ 'Scallop', 'Noddles', 'Comb', 'Dumpling', 'Oyster', 'Table Tennis paddle', 'Cosmetics Brush/Eyeliner Pencil',
56
+ 'Chainsaw', 'Eraser', 'Lobster', 'Durian', 'Okra', 'Lipstick', 'Cosmetics Mirror', 'Curling', 'Table Tennis' ]
57
+
data/scripts/get_argoverse_hd.sh CHANGED
@@ -36,7 +36,7 @@ for val in annotation_files:
36
  img_name = a['images'][img_id]['name']
37
  img_label_name = img_name[:-3] + "txt"
38
 
39
- obj_class = annot['category_id']
40
  x_center, y_center, width, height = annot['bbox']
41
  x_center = (x_center + width / 2) / 1920. # offset and scale
42
  y_center = (y_center + height / 2) / 1200. # offset and scale
@@ -46,11 +46,10 @@ for val in annotation_files:
46
  img_dir = "./labels/" + a['seq_dirs'][a['images'][annot['image_id']]['sid']]
47
 
48
  Path(img_dir).mkdir(parents=True, exist_ok=True)
49
-
50
  if img_dir + "/" + img_label_name not in label_dict:
51
  label_dict[img_dir + "/" + img_label_name] = []
52
 
53
- label_dict[img_dir + "/" + img_label_name].append(f"{obj_class} {x_center} {y_center} {width} {height}\n")
54
 
55
  for filename in label_dict:
56
  with open(filename, "w") as file:
 
36
  img_name = a['images'][img_id]['name']
37
  img_label_name = img_name[:-3] + "txt"
38
 
39
+ cls = annot['category_id'] # instance class id
40
  x_center, y_center, width, height = annot['bbox']
41
  x_center = (x_center + width / 2) / 1920. # offset and scale
42
  y_center = (y_center + height / 2) / 1200. # offset and scale
 
46
  img_dir = "./labels/" + a['seq_dirs'][a['images'][annot['image_id']]['sid']]
47
 
48
  Path(img_dir).mkdir(parents=True, exist_ok=True)
 
49
  if img_dir + "/" + img_label_name not in label_dict:
50
  label_dict[img_dir + "/" + img_label_name] = []
51
 
52
+ label_dict[img_dir + "/" + img_label_name].append(f"{cls} {x_center} {y_center} {width} {height}\n")
53
 
54
  for filename in label_dict:
55
  with open(filename, "w") as file:
data/scripts/get_objects365.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Objects365 https://www.objects365.org labels JSON to YOLO script
2
+ # 1. Download Object 365 from the Object 365 website And unpack all images in datasets/object365/images
3
+ # 2. Place this file and zhiyuan_objv2_train.json file in datasets/objects365
4
+ # 3. Execute this file from datasets/object365 path
5
+ # /datasets
6
+ # /objects365
7
+ # /images
8
+ # /labels
9
+
10
+ from pycocotools.coco import COCO
11
+
12
+ coco = COCO("zhiyuan_objv2_train.json")
13
+ cats = coco.loadCats(coco.getCatIds())
14
+ nms = [cat["name"] for cat in cats]
15
+ print("COCO categories: \n{}\n".format(" ".join(nms)))
16
+ for categoryId, cat in enumerate(nms):
17
+ catIds = coco.getCatIds(catNms=[cat])
18
+ imgIds = coco.getImgIds(catIds=catIds)
19
+ print(cat)
20
+ # Create a subfolder in this directory called "labels". This is where the annotations will be saved in YOLO format
21
+ for im in coco.loadImgs(imgIds):
22
+ width, height = im["width"], im["height"]
23
+ path = im["file_name"].split("/")[-1] # image filename
24
+ try:
25
+ with open("labels/train/" + path.replace(".jpg", ".txt"), "a+") as file:
26
+ annIds = coco.getAnnIds(imgIds=im["id"], catIds=catIds, iscrowd=None)
27
+ for a in coco.loadAnns(annIds):
28
+ x, y, w, h = a['bbox'] # bounding box in xywh (xy top-left corner)
29
+ x, y = x + w / 2, y + h / 2 # xy to center
30
+ file.write(f"{categoryId} {x / width:.5f} {y / height:.5f} {w / width:.5f} {h / height:.5f}\n")
31
+
32
+ except Exception as e:
33
+ print(e)