All Projects → spytensor → Prepare_detection_dataset

spytensor / Prepare_detection_dataset

Licence: mit
convert dataset to coco/voc format

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Prepare detection dataset

Efficientdet.pytorch
Implementation EfficientDet: Scalable and Efficient Object Detection in PyTorch
Stars: ✭ 1,383 (+111.47%)
Mutual labels:  coco, detection
Math object detection
An image recognition/object detection model that detects handwritten digits and simple math operators. The output of the predicted objects (numbers & math operators) is then evaluated and solved.
Stars: ✭ 52 (-92.05%)
Mutual labels:  coco, detection
Coco Annotator
✏️ Web-based image segmentation tool for object detection, localization, and keypoints
Stars: ✭ 1,138 (+74.01%)
Mutual labels:  coco, detection
Pytorch Imagenet Cifar Coco Voc Training
Training examples and results for ImageNet(ILSVRC2012)/CIFAR100/COCO2017/VOC2007+VOC2012 datasets.Image Classification/Object Detection.Include ResNet/EfficientNet/VovNet/DarkNet/RegNet/RetinaNet/FCOS/CenterNet/YOLOv3.
Stars: ✭ 130 (-80.12%)
Mutual labels:  coco, detection
Up Detr
[CVPR2021 Oral] UP-DETR: Unsupervised Pre-training for Object Detection with Transformers
Stars: ✭ 126 (-80.73%)
Mutual labels:  coco, detection
Fastmaskrcnn
Mask RCNN in TensorFlow
Stars: ✭ 3,069 (+369.27%)
Mutual labels:  coco, detection
keras cv attention models
Keras/Tensorflow attention models including beit,botnet,CMT,CoaT,CoAtNet,convnext,cotnet,davit,efficientdet,efficientnet,fbnet,gmlp,halonet,lcnet,levit,mlp-mixer,mobilevit,nfnets,regnet,resmlp,resnest,resnext,resnetd,swin,tinynet,uniformer,volo,wavemlp,yolor,yolox
Stars: ✭ 159 (-75.69%)
Mutual labels:  detection, coco
Foveabox
FoveaBox: Beyond Anchor-based Object Detector
Stars: ✭ 353 (-46.02%)
Mutual labels:  coco, detection
Laracsv
A Laravel package to easily generate CSV files from Eloquent model
Stars: ✭ 583 (-10.86%)
Mutual labels:  csv
Sqlitebiter
A CLI tool to convert CSV / Excel / HTML / JSON / Jupyter Notebook / LDJSON / LTSV / Markdown / SQLite / SSV / TSV / Google-Sheets to a SQLite database file.
Stars: ✭ 601 (-8.1%)
Mutual labels:  csv
Centernet2
Two-stage CenterNet
Stars: ✭ 496 (-24.16%)
Mutual labels:  coco
Tensorflowandroiddemo
TensorFlow android demo 车道线 车辆 人脸 动作 骨架 识别 检测 抽烟 打电话 闭眼 睁眼
Stars: ✭ 589 (-9.94%)
Mutual labels:  detection
Android Yolo
Real-time object detection on Android using the YOLO network with TensorFlow
Stars: ✭ 604 (-7.65%)
Mutual labels:  detection
Vehicle counting tensorflow
🚘 "MORE THAN VEHICLE COUNTING!" This project provides prediction for speed, color and size of the vehicles with TensorFlow Object Counting API.
Stars: ✭ 582 (-11.01%)
Mutual labels:  detection
All About The Gan
All About the GANs(Generative Adversarial Networks) - Summarized lists for GAN
Stars: ✭ 630 (-3.67%)
Mutual labels:  detection
Tabula
Tabula is a tool for liberating data tables trapped inside PDF files
Stars: ✭ 5,420 (+728.75%)
Mutual labels:  csv
Clip
Create charts from the command line
Stars: ✭ 5,111 (+681.5%)
Mutual labels:  csv
Uhttbarcodereference
Universe-HTT barcode reference
Stars: ✭ 634 (-3.06%)
Mutual labels:  csv
Dataproofer
A proofreader for your data
Stars: ✭ 628 (-3.98%)
Mutual labels:  csv
Countries
World countries in JSON, CSV, XML and Yaml. Any help is welcome!
Stars: ✭ 5,379 (+722.48%)
Mutual labels:  csv

背景

万事开头难。之前写图像识别的博客教程,也是为了方便那些学了很多理论知识,却对实际项目无从下手的小伙伴,后来转到目标检测来了,师从烨兄、亚光兄,从他们那学了不少检测的知识和操作,今天也终于闲下了,准备写个检测系列的总结。一方面分享知识希望可以一起学习,另一方面让一部分人少走弯路,快速上路(入坑)。

此部分代码:Github 博客地址: 目标检测系列一:如何制作数据集?

更新

  • (28/03/2019)
    • 新增 csv2labelme

1. 内容介绍

系列一主要介绍如何在常见的几种数据格式之间进行转换,以及万能中介csv格式的使用,这里列出以下几个:

  • csv to coco
  • csv to voc
  • labelme to coco
  • labelme to voc
  • csv to json

2. 标准格式

在使用转换脚本之前,必须要明确的几种格式

2.1 csv

不要一看是csv文件就直接拿来运行,如果不是,可以自行修改代码,或者修改标注文件。

转换脚本支持的csv格式应为以下形式:

  • csv/
    • labels.csv
    • images/
      • image1.jpg
      • image2.jpg
      • ...

labels.csv 的形式:

/path/to/image,xmin,ymin,xmax,ymax,label

例如:

/mfs/dataset/face/0d4c5e4f-fc3c-4d5a-906c-105.jpg,450,154,754,341,face
/mfs/dataset/face/0ddfc5aea-fcdac-421-92dad-144.jpg,143,154,344,341,face
...

注:图片路径请使用绝对路径

2.2 voc

标准的voc数据格式如下:

  • VOC2007/
    • Annotations/
      • 0d4c5e4f-fc3c-4d5a-906c-105.xml
      • 0ddfc5aea-fcdac-421-92dad-144/xml
      • ...
    • ImageSets/
      • Main/
        • train.txt
        • test.txt
        • val.txt
        • trainval.txt
    • JPEGImages/
      • 0d4c5e4f-fc3c-4d5a-906c-105.jpg
      • 0ddfc5aea-fcdac-421-92dad-144.jpg
      • ...
2.3 coco

此处未使用测试集

  • coco/
    • annotations/
      • instances_train2017.json
      • instances_val2017.json
    • images/
      • train2017/
        • 0d4c5e4f-fc3c-4d5a-906c-105.jpg
        • ...
      • val2017
        • 0ddfc5aea-fcdac-421-92dad-144.jpg
        • ...
2.4 labelme
  • labelme/
    • 0d4c5e4f-fc3c-4d5a-906c-105.json
    • 0d4c5e4f-fc3c-4d5a-906c-105.jpg
    • 0ddfc5aea-fcdac-421-92dad-144.json
    • 0ddfc5aea-fcdac-421-92dad-144.jpg

Json file 格式: (imageData那一块太长了,不展示了)

{
  "version": "3.6.16",
  "flags": {},
  "shapes": [
    {
      "label": "helmet",
      "line_color": null,
      "fill_color": null,
      "points": [
        [
          131,
          269
        ],
        [
          388,
          457
        ]
      ],
      "shape_type": "rectangle"
    }
  ],
  "lineColor": [
    0,
    255,
    0,
    128
  ],
  "fillColor": [
    255,
    0,
    0,
    128
  ],
  "imagePath": "004ffe6f-c3e2-3602-84a1-ecd5f437b113.jpg",
  "imageData": ""   # too long ,so not show here
  "imageHeight": 1080,
  "imageWidth": 1920
}

3. 如何使用转换脚本

3.1 csv2coco

首先更改csv2coco.py中以下几个配置

classname_to_id = {"person": 1}  # for your dataset classes
csv_file = "labels.csv"  # annatations file path
image_dir = "images/"    # original image path
saved_coco_path = "./"   # path to save converted coco dataset

然后运行 python csv2coco.py

会自动创建文件夹并复制图片到相应位置,运行结束后得到如下:

  • coco/
    • annotations/
      • instances_train2017.json
      • instances_val2017.json
    • images/
      • train2017/
        • 0d4c5e4f-fc3c-4d5a-906c-105.jpg
        • ...
      • val2017
        • 0ddfc5aea-fcdac-421-92dad-144.jpg
        • ...
3.2 csv2voc

首先更改csv2voc.py中以下几个配置

csv_file = "labels.csv"
saved_path = ".VOC2007/" # path to save converted voc dataset     
image_save_path = "./JPEGImages/"   # converted voc images path
image_raw_parh = "images/"          # original image path

然后运行 python csv2voc.py

同样会自动创建文件夹并复制图片到相应位置,运行结束后得到如下:

  • VOC2007/
    • Annotations/
      • 0d4c5e4f-fc3c-4d5a-906c-105.xml
      • 0ddfc5aea-fcdac-421-92dad-144/xml
      • ...
    • ImageSets/
      • Main/
        • train.txt
        • test.txt
        • val.txt
        • trainval.txt
    • JPEGImages/
      • 0d4c5e4f-fc3c-4d5a-906c-105.jpg
      • 0ddfc5aea-fcdac-421-92dad-144.jpg
      • ...
3.3 labelme2coco

首先更改labelme2coco.py中以下几个配置

classname_to_id = {"person": 1}  # for your dataset classes
labelme_path = "labelme/"  # path for labelme dataset
saved_coco_path = "./"     # path for saved coco dataset

然后运行 python labelme2coco.py,生成文件形式同csv2coco

3.4 labelme2voc

首先更改labelme2voc.py中以下几个配置

labelme_path = "labelme/"  # path for labelme dataset
saved_coco_path = "./"     # path for saved coco dataset

然后运行 python labelme2voc.py,生成文件形式同csv2voc

3.5 csv2labelme

首先更改csv2labelme.py中以下几个配置

image_path = "./images/"  # path for images
csv_file = "./"     # path for csv annotations

然后运行 python csv2labelme.py,生成的json文件会保存在image_path下,切换路径过去,直接labelme便 可以查看标签.

4. 万能中介csv

从上面的转换格式中可以看出,并没有给出如何转到csv的,一是因为太过于简单,而是主流检测框架很少支持这种格式的数据输入。以下给出如何将标注信息写入csv

info = [[filename0,"xmin ymin xmax ymax label0"],
          filename1,"xmin ymin xmax ymax label1"]
csv_labels = open("csv_labels.csv","w")
for filename,bboxes in info:
    bbox = bboxes.split(" ")
    label = bbox[-1]
    csv_labels.write(filename+","+bbox[0]+","+bbox[1]+","+bbox[2]+","+bbox[3]+","+label+"\n")
csv_labels.close()

是不是非常简单。。。如果你不知道如何从原始的标签文件中读取得到标注信息,那没办法了,学学编程吧,23333

TODO

    1. [ ] Multiprocessing
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].