mirror of https://github.com/AlexeyAB/darknet.git
Fixed network resizing (random=1) for non-square networks
This commit is contained in:
parent
cda8171feb
commit
3ebcc647b6
11
src/cuda.c
11
src/cuda.c
|
@ -67,7 +67,16 @@ static int streamInit[16] = { 0 };
|
|||
cudaStream_t get_cuda_stream() {
|
||||
int i = cuda_get_device();
|
||||
if (!streamInit[i]) {
|
||||
cudaStreamCreate(&streamsArray[i]);
|
||||
cudaError_t status = cudaStreamCreate(&streamsArray[i]);
|
||||
//cudaError_t status = cudaStreamCreateWithFlags(&streamsArray[i], cudaStreamNonBlocking);
|
||||
if (status != cudaSuccess) {
|
||||
printf(" cudaStreamCreate error: %d \n", status);
|
||||
const char *s = cudaGetErrorString(status);
|
||||
char buffer[256];
|
||||
printf("CUDA Error: %s\n", s);
|
||||
status = cudaStreamCreateWithFlags(&streamsArray[i], cudaStreamDefault);
|
||||
check_error(status);
|
||||
}
|
||||
streamInit[i] = 1;
|
||||
}
|
||||
return streamsArray[i];
|
||||
|
|
|
@ -66,6 +66,11 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
|||
srand(time(0));
|
||||
network net = nets[0];
|
||||
|
||||
if ((net.batch * net.subdivisions) == 1) {
|
||||
printf("\n Error: You set incorrect value batch=1 for Training! You should set batch=64 subdivision=64 \n");
|
||||
getchar();
|
||||
}
|
||||
|
||||
int imgs = net.batch * net.subdivisions * ngpus;
|
||||
printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
|
||||
data train, buffer;
|
||||
|
@ -121,12 +126,16 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
|||
while(get_current_batch(net) < net.max_batches){
|
||||
if(l.random && count++%10 == 0){
|
||||
printf("Resizing\n");
|
||||
int dim = (rand() % 12 + (init_w/32 - 5)) * 32; // +-160
|
||||
//if (get_current_batch(net)+100 > net.max_batches) dim = 544;
|
||||
//int dim = (rand() % 12 + (init_w/32 - 5)) * 32; // +-160
|
||||
//int dim = (rand() % 4 + 16) * 32;
|
||||
printf("%d\n", dim);
|
||||
args.w = dim;
|
||||
args.h = dim;
|
||||
//if (get_current_batch(net)+100 > net.max_batches) dim = 544;
|
||||
int random_val = rand() % 12;
|
||||
int dim_w = (random_val + (init_w / 32 - 5)) * 32; // +-160
|
||||
int dim_h = (random_val + (init_h / 32 - 5)) * 32; // +-160
|
||||
|
||||
printf("%d x %d \n", dim_w, dim_h);
|
||||
args.w = dim_w;
|
||||
args.h = dim_h;
|
||||
|
||||
pthread_join(load_thread, 0);
|
||||
train = buffer;
|
||||
|
@ -134,7 +143,7 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
|||
load_thread = load_data(args);
|
||||
|
||||
for(i = 0; i < ngpus; ++i){
|
||||
resize_network(nets + i, dim, dim);
|
||||
resize_network(nets + i, dim_w, dim_h);
|
||||
}
|
||||
net = nets[0];
|
||||
}
|
||||
|
|
|
@ -950,7 +950,7 @@ image load_image_cv(char *filename, int channels)
|
|||
sprintf(buff, "echo %s >> bad.list", filename);
|
||||
system(buff);
|
||||
return make_image(10,10,3);
|
||||
//exit(0);
|
||||
//exit(EXIT_FAILURE);
|
||||
}
|
||||
image out = ipl_to_image(src);
|
||||
cvReleaseImage(&src);
|
||||
|
@ -1691,7 +1691,11 @@ image load_image_stb(char *filename, int channels)
|
|||
unsigned char *data = stbi_load(filename, &w, &h, &c, channels);
|
||||
if (!data) {
|
||||
fprintf(stderr, "Cannot load image \"%s\"\nSTB Reason: %s\n", filename, stbi_failure_reason());
|
||||
exit(1);
|
||||
char buff[256];
|
||||
sprintf(buff, "echo %s >> bad.list", filename);
|
||||
system(buff);
|
||||
return make_image(10, 10, 3);
|
||||
//exit(EXIT_FAILURE);
|
||||
}
|
||||
if(channels) c = channels;
|
||||
int i,j,k;
|
||||
|
|
|
@ -208,19 +208,19 @@ void error(const char *s)
|
|||
{
|
||||
perror(s);
|
||||
assert(0);
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void malloc_error()
|
||||
{
|
||||
fprintf(stderr, "Malloc error\n");
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void file_error(char *s)
|
||||
{
|
||||
fprintf(stderr, "Couldn't open file: %s\n", s);
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
list *split_str(char *s, char delim)
|
||||
|
|
Loading…
Reference in New Issue