Skip to content
This repository was archived by the owner on Aug 19, 2023. It is now read-only.

Commit 09081af

Browse files
committed
readme update
1 parent b644323 commit 09081af

File tree

1 file changed

+108
-11
lines changed

1 file changed

+108
-11
lines changed

README.md

Lines changed: 108 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,113 @@
11
# pytorch-retinanet
22

3-
WIP
43

4+
Pytorch implementation of RetinaNet object detection as described in [Focal Loss for Dense Object Detection](https://arxiv.org/abs/1708.02002) by Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He and Piotr Dollár.
55

6-
# dependencies
76

8-
sudo pip install cffi
9-
sudo pip install pandas
10-
sudo pip install pycocotools
11-
sudo pip install cython
12-
sudo pip install pycocotools
13-
sudo apt-get install tk-dev
14-
sudo apt-get install python-tk
15-
sudo pip install opencv-python
16-
sudo pip install requests
7+
## Results
8+
Currently, this repo achieves 33.7% mAP at 600px resolution with a Resnet-50 backbone. The published result is 34.0% mAP. The difference is likely due to the use of Adam optimizer instead of SGD with weight decay.
9+
10+
## Installation
11+
12+
1) Clone this repo
13+
14+
2) Install the required packages:
15+
16+
```
17+
apt-get install tk-dev python-tk
18+
```
19+
20+
3) Install the python packages:
21+
22+
```
23+
pip install cffi
24+
25+
pip install pandas
26+
27+
pip install pycocotools
28+
29+
pip install cython
30+
31+
pip install pycocotools
32+
33+
pip install opencv-python
34+
35+
pip install requests
36+
37+
```
38+
39+
4) Build the NMS extension.
40+
41+
## Training
42+
43+
The network can be trained using the `train.py` script. Currently, two dataloaders are available: COCO and CSV. For training on coco, use
44+
45+
```
46+
python train.py coco <path/to/coco>
47+
```
48+
49+
For training using a custom dataset, with annotations in CSV format (see below), use
50+
51+
```
52+
python train.py csv <path/to/annotations.csv> <path/to/classes.csv>
53+
```
54+
55+
## Visualization
56+
57+
To visualize the network detection, use `test.py`.
58+
59+
## CSV datasets
60+
The `CSVGenerator` provides an easy way to define your own datasets.
61+
It uses two CSV files: one file containing annotations and one file containing a class name to ID mapping.
62+
63+
### Annotations format
64+
The CSV file with annotations should contain one annotation per line.
65+
Images with multiple bounding boxes should use one row per bounding box.
66+
Note that indexing for pixel values starts at 0.
67+
The expected format of each line is:
68+
```
69+
path/to/image.jpg,x1,y1,x2,y2,class_name
70+
```
71+
72+
Some images may not contain any labeled objects.
73+
To add these images to the dataset as negative examples,
74+
add an annotation where `x1`, `y1`, `x2`, `y2` and `class_name` are all empty:
75+
```
76+
path/to/image.jpg,,,,,
77+
```
78+
79+
A full example:
80+
```
81+
/data/imgs/img_001.jpg,837,346,981,456,cow
82+
/data/imgs/img_002.jpg,215,312,279,391,cat
83+
/data/imgs/img_002.jpg,22,5,89,84,bird
84+
/data/imgs/img_003.jpg,,,,,
85+
```
86+
87+
This defines a dataset with 3 images.
88+
`img_001.jpg` contains a cow.
89+
`img_002.jpg` contains a cat and a bird.
90+
`img_003.jpg` contains no interesting objects/animals.
91+
92+
93+
### Class mapping format
94+
The class name to ID mapping file should contain one mapping per line.
95+
Each line should use the following format:
96+
```
97+
class_name,id
98+
```
99+
100+
Indexing for classes starts at 0.
101+
Do not include a background class as it is implicit.
102+
103+
For example:
104+
```
105+
cow,0
106+
cat,1
107+
bird,2
108+
```
109+
110+
## Acknowledgements
111+
112+
- Significant amounts of code are borrowed from the [keras retinanet implementation](https://github.com/fizyr/keras-retinanet)
113+
- The NMS module used is from the [pytorch faster-rcnn implementation](https://github.com/ruotianluo/pytorch-faster-rcnn)

0 commit comments

Comments
 (0)