pjreddie / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
25.74k stars 21.33k forks source link

good training infomation shown but test result is bad,why? #441

Open AhaEdgar opened 6 years ago

AhaEdgar commented 6 years ago
22786: 0.340005, 0.431032 avg, 0.000400 rate, 9.582244 seconds, 5833216 images
Loaded: 0.000059 seconds
Region Avg IOU: 0.867003, Class: 0.934828, Obj: 0.824453, No Obj: 0.003912, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.880843, Class: 0.989937, Obj: 0.891789, No Obj: 0.002898, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.869872, Class: 0.924840, Obj: 0.824599, No Obj: 0.003627, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.876178, Class: 0.916465, Obj: 0.851787, No Obj: 0.003209, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.861706, Class: 0.997763, Obj: 0.865688, No Obj: 0.003048, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.898642, Class: 0.981886, Obj: 0.801552, No Obj: 0.002264, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.860486, Class: 0.888588, Obj: 0.860497, No Obj: 0.002777, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.856618, Class: 0.989835, Obj: 0.893207, No Obj: 0.003139, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.846072, Class: 0.998710, Obj: 0.869655, No Obj: 0.003681, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.824677, Class: 0.985160, Obj: 0.846752, No Obj: 0.002444, Avg Recall: 1.000000,  count: 9
Region Avg IOU: 0.874953, Class: 0.984092, Obj: 0.887963, No Obj: 0.003462, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.894702, Class: 0.931563, Obj: 0.889824, No Obj: 0.003575, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.875531, Class: 0.991035, Obj: 0.855262, No Obj: 0.003678, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.863448, Class: 0.998233, Obj: 0.892676, No Obj: 0.003015, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.862992, Class: 0.995424, Obj: 0.848635, No Obj: 0.003201, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.899600, Class: 0.977886, Obj: 0.908572, No Obj: 0.002938, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.860666, Class: 0.986191, Obj: 0.855068, No Obj: 0.002611, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.874312, Class: 0.989023, Obj: 0.892241, No Obj: 0.003257, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.875347, Class: 0.995299, Obj: 0.901929, No Obj: 0.003009, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.848832, Class: 0.995653, Obj: 0.902537, No Obj: 0.002623, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.827308, Class: 0.993255, Obj: 0.877097, No Obj: 0.003377, Avg Recall: 1.000000,  count: 8
Region Avg IOU: 0.868614, Class: 0.998942, Obj: 0.889489, No Obj: 0.003070, Avg Recall: 1.000000,  count: 8

the test result is 8% every class .....T T

patrick-ucr commented 6 years ago

Yes Loss, IOU, Recall look good but why Class is less than 1? What does cfg's [region] look like?

AhaEdgar commented 6 years ago
[region]
anchors =  1.3221, 1.73145, 3.19275, 4.00944, 5.05587, 8.09892, 9.47112, 4.84053, 11.2364, 10.0071
bias_match=1
classes=6
coords=4
num=5  #5
softmax=1
jitter=.3
rescore=1

object_scale=5
noobject_scale=1
class_scale=1
coord_scale=1

absolute=1
thresh = .6
random=0 #1

I use the input size 608 * 608 and modify the network structure @patrick-ucr

patrick-ucr commented 6 years ago

2 things observed. Are you training VOC datasets? Because anchors look different from the default values for VOC. Second, your datasets might be too small because the network should have seen 6 classes not 0.9xxx like the log shows. This may explain why you have good results. Check your training sets that should be large enough and share some characteristics with the test sets.

AhaEdgar commented 6 years ago

thanks for your advice. my dataset has 3000 images for training,most of training images has only one class. I don't understand the meaning of “Class:0.9xxx” ,I had thought it means good results close to1. can u tell me more about the “Class:6.0000”or“Class:0.9”? @patrick-ucr

patrick-ucr commented 6 years ago

@Ahagpp I am not sure about that but I am training a network to detect "one" class of objects and my class numbers are always "1.000000". I suggest you check annotation+datasets, make sure that classes are numbers 0-5 according to your .names file.

AhaEdgar commented 6 years ago

I modify my data/voc.names for training. the file like this

bus
microbus
minivan
sedan
suv
truck

I have checked the labels/xxxx.txt , the 0-5 number is right @patrick-ucr

patrick-ucr commented 6 years ago

your voc.names looks good but you have to check annotation txt files in VOCdevkit/VOC2007/labels/ and make sure that they have in each line like this sample 0 0.516417910448 0.501 0.202985074627 0.202 where the first number should be 0-5 which represents your object classes in voc.names. For example, 0 means bus, 1 means microbus, and on and on. Hope this helps.

AhaEdgar commented 6 years ago

I have checked the files what you said. txt files seem to have no problem. did u modify example/yolo.c this file?

 #include "darknet.h"

char *voc_names[] = {"aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"};

void train_yolo(char *cfgfile, char *weightfile)
{
    char *train_images = "/data/voc/train.txt";
    char *backup_directory = "/home/pjreddie/backup/";
    srand(time(0));
    char *base = basecfg(cfgfile);
    printf("%s\n", base);
    float avg_loss = -1;
    network *net = load_network(cfgfile, weightfile, 0);
    printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay);
    int imgs = net->batch*net->subdivisions;
    int i = *net->seen/imgs;
    data train, buffer;

    layer l = net->layers[net->n - 1];

    int side = l.side;
    int classes = l.classes;
    float jitter = l.jitter;

    list *plist = get_paths(train_images);
    //int N = plist->size;
    char **paths = (char **)list_to_array(plist);
.....
.....

I didn't modify this file, maybe this is the reason?@patrick-ucr

muyue1238 commented 6 years ago

That is the problem, you should change voc_names[] according to your own dataset. There are several places also need changes, it's easy to find out how and where in other issues.

MirwanHakim commented 4 years ago

Why my result is Region Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.003070, .5R: -nan, .75R: -nan, count: 0

what wrong? any body can help me

Vxtzq commented 1 year ago

I think you should post a new issue or find an existing one for that problem, but I already had this problem, perhaps you forgot something in the yolo.cfg file but it's hard to say because you gave no information (give the train command and other things like classes, num of images etc).

Vxtzq commented 1 year ago

quite a late response :o lol