| | |
| | | height=256 |
| | | width=256 |
| | | channels=3 |
| | | learning_rate=0.0000001 |
| | | learning_rate=0.000001 |
| | | momentum=0.9 |
| | | decay=0.0005 |
| | | seen=0 |
| | |
| | | int i; |
| | | image t = make_image(im.w, im.h, im.c); |
| | | for(i = 0; i < im.w*im.h*im.c; ++i){ |
| | | t.data[i] = im.data[i]>0 ? 1 : 0; |
| | | t.data[i] = im.data[i]>thresh ? 1 : 0; |
| | | } |
| | | return t; |
| | | } |
| | |
| | | float val = (1-dy) * get_pixel(part, c, iy, k); |
| | | set_pixel(resized, c, r, k, val); |
| | | } |
| | | if(r == h-1) continue; |
| | | if(r == h-1 || im.h == 1) continue; |
| | | for(c = 0; c < w; ++c){ |
| | | float val = dy * get_pixel(part, c, iy+1, k); |
| | | add_pixel(resized, c, r, k, val); |
| | |
| | | avg_loss = avg_loss*.9 + loss*.1; |
| | | printf("%d, %.3f: %f, %f avg, %f rate, %lf seconds, %d images\n", get_current_batch(net), (float)(*net.seen)/N, loss, avg_loss, get_current_rate(net), sec(clock()-time), *net.seen); |
| | | free_data(train); |
| | | if(get_current_batch(net)%100 == 0){ |
| | | char buff[256]; |
| | | sprintf(buff, "%s/%s_batch_%d.weights", backup_directory, base, get_current_batch(net)); |
| | | save_weights(net, buff); |
| | | } |
| | | if(*net.seen/N > epoch){ |
| | | epoch = *net.seen/N; |
| | | char buff[256]; |
| | |
| | | printf("%s: Predicted in %f seconds.\n", filename, sec(clock()-time)); |
| | | image pred = get_network_image(net); |
| | | |
| | | image t = threshold_image(pred, .2); |
| | | image t = threshold_image(pred, .5); |
| | | free_image(pred); |
| | | pred = t; |
| | | |
| | |
| | | printf("Save image as %s.png (shape: %d %d)\n", outfile, pred.w, pred.h); |
| | | save_image(pred, outfile); |
| | | } else { |
| | | show_image(sized, "orig"); |
| | | show_image(pred, "prediction"); |
| | | #ifdef OPENCV |
| | | cvWaitKey(0); |