Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

SKU-110K.yaml 2.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  1. # YOLOv5 🚀 by Ultralytics, GPL-3.0 license
  2. # SKU-110K retail items dataset https://github.com/eg4000/SKU110K_CVPR19
  3. # Example usage: python train.py --data SKU-110K.yaml
  4. # parent
  5. # ├── yolov5
  6. # └── datasets
  7. # └── SKU-110K ← downloads here
  8. # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
  9. path: ../datasets/SKU-110K # dataset root dir
  10. train: train.txt # train images (relative to 'path') 8219 images
  11. val: val.txt # val images (relative to 'path') 588 images
  12. test: test.txt # test images (optional) 2936 images
  13. # Classes
  14. nc: 1 # number of classes
  15. names: ['object'] # class names
  16. # Download script/URL (optional) ---------------------------------------------------------------------------------------
  17. download: |
  18. import shutil
  19. from tqdm import tqdm
  20. from utils.general import np, pd, Path, download, xyxy2xywh
  21. # Download
  22. dir = Path(yaml['path']) # dataset root dir
  23. parent = Path(dir.parent) # download dir
  24. urls = ['http://trax-geometry.s3.amazonaws.com/cvpr_challenge/SKU110K_fixed.tar.gz']
  25. download(urls, dir=parent, delete=False)
  26. # Rename directories
  27. if dir.exists():
  28. shutil.rmtree(dir)
  29. (parent / 'SKU110K_fixed').rename(dir) # rename dir
  30. (dir / 'labels').mkdir(parents=True, exist_ok=True) # create labels dir
  31. # Convert labels
  32. names = 'image', 'x1', 'y1', 'x2', 'y2', 'class', 'image_width', 'image_height' # column names
  33. for d in 'annotations_train.csv', 'annotations_val.csv', 'annotations_test.csv':
  34. x = pd.read_csv(dir / 'annotations' / d, names=names).values # annotations
  35. images, unique_images = x[:, 0], np.unique(x[:, 0])
  36. with open((dir / d).with_suffix('.txt').__str__().replace('annotations_', ''), 'w') as f:
  37. f.writelines(f'./images/{s}\n' for s in unique_images)
  38. for im in tqdm(unique_images, desc=f'Converting {dir / d}'):
  39. cls = 0 # single-class dataset
  40. with open((dir / 'labels' / im).with_suffix('.txt'), 'a') as f:
  41. for r in x[images == im]:
  42. w, h = r[6], r[7] # image width, height
  43. xywh = xyxy2xywh(np.array([[r[1] / w, r[2] / h, r[3] / w, r[4] / h]]))[0] # instance
  44. f.write(f"{cls} {xywh[0]:.5f} {xywh[1]:.5f} {xywh[2]:.5f} {xywh[3]:.5f}\n") # write label
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...