| 3 | static int coco_ids[] = {1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,31,32,33,34,35,36,37,38,39,40,41,42,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,70,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90}; |
| 4 | |
| 5 | void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, int ngpus, int clear) |
| 6 | { |
| 7 | list *options = read_data_cfg(datacfg); |
| 8 | char *train_images = option_find_str(options, "train", "data/train.list"); |
| 9 | char *backup_directory = option_find_str(options, "backup", "/backup/"); |
| 10 | |
| 11 | srand(time(0)); |
| 12 | char *base = basecfg(cfgfile); |
| 13 | printf("%s\n", base); |
| 14 | float avg_loss = -1; |
| 15 | network **nets = calloc(ngpus, sizeof(network)); |
| 16 | |
| 17 | srand(time(0)); |
| 18 | int seed = rand(); |
| 19 | int i; |
| 20 | for(i = 0; i < ngpus; ++i){ |
| 21 | srand(seed); |
| 22 | #ifdef GPU |
| 23 | cuda_set_device(gpus[i]); |
| 24 | #endif |
| 25 | nets[i] = load_network(cfgfile, weightfile, clear); |
| 26 | nets[i]->learning_rate *= ngpus; |
| 27 | } |
| 28 | srand(time(0)); |
| 29 | network *net = nets[0]; |
| 30 | |
| 31 | int imgs = net->batch * net->subdivisions * ngpus; |
| 32 | printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay); |
| 33 | data train, buffer; |
| 34 | |
| 35 | layer l = net->layers[net->n - 1]; |
| 36 | |
| 37 | int classes = l.classes; |
| 38 | float jitter = l.jitter; |
| 39 | |
| 40 | list *plist = get_paths(train_images); |
| 41 | //int N = plist->size; |
| 42 | char **paths = (char **)list_to_array(plist); |
| 43 | |
| 44 | load_args args = get_base_args(net); |
| 45 | args.coords = l.coords; |
| 46 | args.paths = paths; |
| 47 | args.n = imgs; |
| 48 | args.m = plist->size; |
| 49 | args.classes = classes; |
| 50 | args.jitter = jitter; |
| 51 | args.num_boxes = l.max_boxes; |
| 52 | args.d = &buffer; |
| 53 | args.type = DETECTION_DATA; |
| 54 | //args.type = INSTANCE_DATA; |
| 55 | args.threads = 64; |
| 56 | |
| 57 | pthread_t load_thread = load_data(args); |
| 58 | double time; |
| 59 | int count = 0; |
| 60 | //while(i*imgs < N*120){ |
| 61 | while(get_current_batch(net) < net->max_batches){ |
| 62 | if(l.random && count++%10 == 0){ |
no test coverage detected