mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
fixed bug: rand() for batches of images
This commit is contained in:
@ -44,10 +44,12 @@ char **get_random_paths(char **paths, int n, int m)
|
|||||||
char **random_paths = calloc(n, sizeof(char*));
|
char **random_paths = calloc(n, sizeof(char*));
|
||||||
int i;
|
int i;
|
||||||
pthread_mutex_lock(&mutex);
|
pthread_mutex_lock(&mutex);
|
||||||
|
//printf("n = %d \n", n);
|
||||||
for(i = 0; i < n; ++i){
|
for(i = 0; i < n; ++i){
|
||||||
int index = rand()%m;
|
int index = (rand()*rand())%m;
|
||||||
random_paths[i] = paths[index];
|
random_paths[i] = paths[index];
|
||||||
//if(i == 0) printf("%s\n", paths[index]);
|
//if(i == 0) printf("%s\n", paths[index]);
|
||||||
|
//printf("%s\n", paths[index]);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
return random_paths;
|
return random_paths;
|
||||||
@ -714,6 +716,7 @@ data load_data_detection(int n, char **paths, int m, int w, int h, int boxes, in
|
|||||||
|
|
||||||
void *load_thread(void *ptr)
|
void *load_thread(void *ptr)
|
||||||
{
|
{
|
||||||
|
srand(time(0));
|
||||||
//printf("Loading data: %d\n", rand());
|
//printf("Loading data: %d\n", rand());
|
||||||
load_args a = *(struct load_args*)ptr;
|
load_args a = *(struct load_args*)ptr;
|
||||||
if(a.exposure == 0) a.exposure = 1;
|
if(a.exposure == 0) a.exposure = 1;
|
||||||
@ -757,6 +760,7 @@ pthread_t load_data_in_thread(load_args args)
|
|||||||
|
|
||||||
void *load_threads(void *ptr)
|
void *load_threads(void *ptr)
|
||||||
{
|
{
|
||||||
|
srand(time(0));
|
||||||
int i;
|
int i;
|
||||||
load_args args = *(load_args *)ptr;
|
load_args args = *(load_args *)ptr;
|
||||||
if (args.threads == 0) args.threads = 1;
|
if (args.threads == 0) args.threads = 1;
|
||||||
|
@ -78,7 +78,7 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
//while(i*imgs < N*120){
|
//while(i*imgs < N*120){
|
||||||
while(get_current_batch(net) < net.max_batches){
|
while(get_current_batch(net) < net.max_batches){
|
||||||
if(l.random && count++%10 == 0){
|
if(l.random && count++%10 == 0){
|
||||||
printf("Resizing\n");
|
printf("Resizing\n");
|
||||||
int dim = (rand() % 10 + 10) * 32;
|
int dim = (rand() % 10 + 10) * 32;
|
||||||
if (get_current_batch(net)+100 > net.max_batches) dim = 544;
|
if (get_current_batch(net)+100 > net.max_batches) dim = 544;
|
||||||
|
Reference in New Issue
Block a user