Open dexception opened 5 years ago
@dexception did you try the section https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects? Yes, there's stuff to figure out, but it's mostly worked for me and if you run into a question, I'll try to answer it.
I've prepared starter template for image classification in https://github.com/jing-vision/lightnet/tree/master/__template-darknet19_448
@Jacob-Stevens-Haas I am not talking about object detection.
This is simple and pure image classification without any coordinates.
There is info on this, on pjreddie's site.
For those that are just doing classification this is the command:
./darknet classifier train cfg/your.data cfg/your.cfg
@AlexeyAB
@AlexeyAB I have been stuck on this issue for a long time. Can you plz reply. Thanks.
@deimsdeutsch
- Can you tell me what would be the format of the .txt file for each image ?
There shouldn't be txt-file for each image. Each jpg-file should contain label
in its filename.
You should set here 1000 for 1000 classes: https://github.com/AlexeyAB/darknet/blob/3e2ef94130a8b4cf8c4b8d3c7a6f345d92531f65/cfg/darknet53.cfg#L558
You should have cfg/obj.data
file
classes=1000
train = train.txt
valid = valid.txt
backup = backup
labels = labels.list
names = shortnames.list
top=5
classes - number of classes, for example = 1000
labels.list
- file with list of 1000 labels (for example: n1
, n2
, n3
, ... n1000
)
train.txt
- file with list of jpg-files for training, each name should contain one of label, for example image_n1.jpg
, img.n2.jpg
, n3.jpg
, ...
shortnames.list
- file with list of 1000 names of classes car
, dog
top=5 - what accuracy will be checked top1, top5, topN....
valid.list
- file with list of jpg-files for validation
darknet.exe classifier train cfg/obj.data cfg/darknet53.cfg -topk
darknet.exe classifier valid cfg/obj.data cfg/darknet53.cfg backup/darknet53_last.weights
@AlexeyAB Thanks for replying.
I am assuming from your reply that right now there is not way to fetch the classification categories in python3.
root@dimsdeutsch-GL553VE:/opt/project1/darknet# ./darknet classifier predict cfg/imagenet1k.data cfg/darknet19.cfg darknet19.weights data/dog.jpg layer filters size input output 0 conv 32 3 x 3 / 1 224 x 224 x 3 -> 224 x 224 x 32 0.087 BF 1 max 2 x 2 / 2 224 x 224 x 32 -> 112 x 112 x 32 0.002 BF 2 conv 64 3 x 3 / 1 112 x 112 x 32 -> 112 x 112 x 64 0.462 BF 3 max 2 x 2 / 2 112 x 112 x 64 -> 56 x 56 x 64 0.001 BF 4 conv 128 3 x 3 / 1 56 x 56 x 64 -> 56 x 56 x 128 0.462 BF 5 conv 64 1 x 1 / 1 56 x 56 x 128 -> 56 x 56 x 64 0.051 BF 6 conv 128 3 x 3 / 1 56 x 56 x 64 -> 56 x 56 x 128 0.462 BF 7 max 2 x 2 / 2 56 x 56 x 128 -> 28 x 28 x 128 0.000 BF 8 conv 256 3 x 3 / 1 28 x 28 x 128 -> 28 x 28 x 256 0.462 BF 9 conv 128 1 x 1 / 1 28 x 28 x 256 -> 28 x 28 x 128 0.051 BF 10 conv 256 3 x 3 / 1 28 x 28 x 128 -> 28 x 28 x 256 0.462 BF 11 max 2 x 2 / 2 28 x 28 x 256 -> 14 x 14 x 256 0.000 BF 12 conv 512 3 x 3 / 1 14 x 14 x 256 -> 14 x 14 x 512 0.462 BF 13 conv 256 1 x 1 / 1 14 x 14 x 512 -> 14 x 14 x 256 0.051 BF 14 conv 512 3 x 3 / 1 14 x 14 x 256 -> 14 x 14 x 512 0.462 BF 15 conv 256 1 x 1 / 1 14 x 14 x 512 -> 14 x 14 x 256 0.051 BF 16 conv 512 3 x 3 / 1 14 x 14 x 256 -> 14 x 14 x 512 0.462 BF 17 max 2 x 2 / 2 14 x 14 x 512 -> 7 x 7 x 512 0.000 BF 18 conv 1024 3 x 3 / 1 7 x 7 x 512 -> 7 x 7 x1024 0.462 BF 19 conv 512 1 x 1 / 1 7 x 7 x1024 -> 7 x 7 x 512 0.051 BF 20 conv 1024 3 x 3 / 1 7 x 7 x 512 -> 7 x 7 x1024 0.462 BF 21 conv 512 1 x 1 / 1 7 x 7 x1024 -> 7 x 7 x 512 0.051 BF 22 conv 1024 3 x 3 / 1 7 x 7 x 512 -> 7 x 7 x1024 0.462 BF 23 conv 1000 1 x 1 / 1 7 x 7 x1024 -> 7 x 7 x1000 0.100 BF 24 avg 7 x 7 x1000 -> 1000 25 softmax 1000 26 cost 1000 Total BFLOPS 5.585 Allocate additional workspace_size = 52.43 MB Loading weights from darknet19.weights... seen 32 Done!
try to allocate additional workspace_size = 52.43 MB CUDA allocate done! 224 224 data/dog.jpg: Predicted in 0.001283 seconds. Eskimo dog: 0.277704 malamute: 0.153123 Siberian husky: 0.138571 German shepherd: 0.046391 miniature schnauzer: 0.038783
But not getting the same output from darknet.py file.
root@dimsdeutsch-GL553VE:/opt/project1/darknet# python3 darknet.py Try to load cfg: ./cfg/darknet19.cfg, weights: darknet19.weights, clear = 0 layer filters size input output 0 conv 32 3 x 3 / 1 224 x 224 x 3 -> 224 x 224 x 32 0.087 BF 1 max 2 x 2 / 2 224 x 224 x 32 -> 112 x 112 x 32 0.002 BF 2 conv 64 3 x 3 / 1 112 x 112 x 32 -> 112 x 112 x 64 0.462 BF 3 max 2 x 2 / 2 112 x 112 x 64 -> 56 x 56 x 64 0.001 BF 4 conv 128 3 x 3 / 1 56 x 56 x 64 -> 56 x 56 x 128 0.462 BF 5 conv 64 1 x 1 / 1 56 x 56 x 128 -> 56 x 56 x 64 0.051 BF 6 conv 128 3 x 3 / 1 56 x 56 x 64 -> 56 x 56 x 128 0.462 BF 7 max 2 x 2 / 2 56 x 56 x 128 -> 28 x 28 x 128 0.000 BF 8 conv 256 3 x 3 / 1 28 x 28 x 128 -> 28 x 28 x 256 0.462 BF 9 conv 128 1 x 1 / 1 28 x 28 x 256 -> 28 x 28 x 128 0.051 BF 10 conv 256 3 x 3 / 1 28 x 28 x 128 -> 28 x 28 x 256 0.462 BF 11 max 2 x 2 / 2 28 x 28 x 256 -> 14 x 14 x 256 0.000 BF 12 conv 512 3 x 3 / 1 14 x 14 x 256 -> 14 x 14 x 512 0.462 BF 13 conv 256 1 x 1 / 1 14 x 14 x 512 -> 14 x 14 x 256 0.051 BF 14 conv 512 3 x 3 / 1 14 x 14 x 256 -> 14 x 14 x 512 0.462 BF 15 conv 256 1 x 1 / 1 14 x 14 x 512 -> 14 x 14 x 256 0.051 BF 16 conv 512 3 x 3 / 1 14 x 14 x 256 -> 14 x 14 x 512 0.462 BF 17 max 2 x 2 / 2 14 x 14 x 512 -> 7 x 7 x 512 0.000 BF 18 conv 1024 3 x 3 / 1 7 x 7 x 512 -> 7 x 7 x1024 0.462 BF 19 conv 512 1 x 1 / 1 7 x 7 x1024 -> 7 x 7 x 512 0.051 BF 20 conv 1024 3 x 3 / 1 7 x 7 x 512 -> 7 x 7 x1024 0.462 BF 21 conv 512 1 x 1 / 1 7 x 7 x1024 -> 7 x 7 x 512 0.051 BF 22 conv 1024 3 x 3 / 1 7 x 7 x 512 -> 7 x 7 x1024 0.462 BF 23 conv 1000 1 x 1 / 1 7 x 7 x1024 -> 7 x 7 x1000 0.100 BF 24 avg 7 x 7 x1000 -> 1000 25 softmax 1000 26 cost 1000 Total BFLOPS 5.585 Allocate additional workspace_size = 52.43 MB Loading weights from darknet19.weights... seen 32 Done! Loaded - names_list: data/imagenet.shortnames.list, classes = 1000 []
@deimsdeutsch Yes, darknet.py is just a simple example for Yolo detection.
@AlexeyAB I am looking forward for the python wrapper for classification. It would be a good addition to the project.
@deimsdeutsch
- Can you tell me what would be the format of the .txt file for each image ?
There shouldn't be txt-file for each image. Each jpg-file should contain
label
in its filename.You should set here 1000 for 1000 classes:
You should have
cfg/obj.data
fileclasses=1000 train = train.txt valid = valid.txt backup = backup labels = labels.list names = shortnames.list top=5
- classes - number of classes, for example =
1000
labels.list
- file with list of 1000 labels (for example:n1
,n2
,n3
, ...n1000
)train.txt
- file with list of jpg-files for training, each name should contain one of label, for exampleimage_n1.jpg
,img.n2.jpg
,n3.jpg
, ...shortnames.list
- file with list of 1000 names of classescar
,dog
- top=5 - what accuracy will be checked top1, top5, topN....
valid.list
- file with list of jpg-files for validation
- or during detection
darknet.exe classifier train cfg/obj.data cfg/darknet53.cfg -topk
- or separate validation
darknet.exe classifier valid cfg/obj.data cfg/darknet53.cfg backup/darknet53_last.weights
@AlexeyAB Hi,I have 4000 classes dataset.Can I train my dataset with this method?
Hi @AlexeyAB ,
I want to do just classification of images using darknet. I have looked everywhere but could find the steps. Can you please help me in this regard ..
Thanks