Fixed memory leaks for Yolo: train, test
| | |
| | | <Optimization>Disabled</Optimization> |
| | | <SDLCheck>true</SDLCheck> |
| | | <AdditionalIncludeDirectories>C:\opencv_3.0\opencv\build\include;..\..\3rdparty\include;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir);$(cudnn)\include</AdditionalIncludeDirectories> |
| | | <PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;_MBCS;_TIMESPEC_DEFINED;_CRT_SECURE_NO_WARNINGS;_CRT_RAND_S;GPU;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
| | | <UndefinePreprocessorDefinitions>CUDNN;OPENCV;</UndefinePreprocessorDefinitions> |
| | | <PreprocessorDefinitions>CUDNN;_CRTDBG_MAP_ALLOC;_MBCS;_TIMESPEC_DEFINED;_CRT_SECURE_NO_WARNINGS;_CRT_RAND_S;GPU;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
| | | <UndefinePreprocessorDefinitions>OPENCV;</UndefinePreprocessorDefinitions> |
| | | <MultiProcessorCompilation>true</MultiProcessorCompilation> |
| | | <ForcedIncludeFiles>stdlib.h;crtdbg.h;%(ForcedIncludeFiles)</ForcedIncludeFiles> |
| | | </ClCompile> |
| | | <Link> |
| | | <GenerateDebugInformation>true</GenerateDebugInformation> |
| | |
| | | size_t total_byte; |
| | | check_error(cudaMemGetInfo(&free_byte, &total_byte)); |
| | | if (l->workspace_size > free_byte || l->workspace_size >= total_byte / 2) { |
| | | printf(" used slow CUDNN algo without Workspace! Need memory: %d, available: %d\n", l->workspace_size, (free_byte < total_byte/2) ? free_byte : total_byte/2); |
| | | printf(" used slow CUDNN algo without Workspace! Need memory: %zu, available: %zu\n", l->workspace_size, (free_byte < total_byte/2) ? free_byte : total_byte/2); |
| | | cudnn_convolutional_setup(l, cudnn_smallest); |
| | | l->workspace_size = get_workspace_size(*l); |
| | | } |
| | |
| | | cvReleaseVideoWriter(&output_video_writer); |
| | | printf("output_video_writer closed. \n"); |
| | | } |
| | | |
| | | // free memory |
| | | cvReleaseImage(&show_img); |
| | | cvReleaseImage(&in_img); |
| | | free_image(in_s); |
| | | |
| | | free(avg); |
| | | for (j = 0; j < FRAMES; ++j) free(predictions[j]); |
| | | for (j = 0; j < FRAMES; ++j) free_image(images[j]); |
| | | |
| | | for (j = 0; j < l.w*l.h*l.n; ++j) free(probs[j]); |
| | | free(boxes); |
| | | free(probs); |
| | | |
| | | free_ptrs(names, net.layers[net.n - 1].classes); |
| | | |
| | | int i; |
| | | const int nsize = 8; |
| | | for (j = 0; j < nsize; ++j) { |
| | | for (i = 32; i < 127; ++i) { |
| | | free_image(alphabet[j][i]); |
| | | } |
| | | free(alphabet[j]); |
| | | } |
| | | free(alphabet); |
| | | |
| | | free_network(net); |
| | | } |
| | | #else |
| | | void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int cam_index, const char *filename, char **names, int classes, |
| | |
| | | #ifdef _DEBUG |
| | | #include <stdlib.h> |
| | | #include <crtdbg.h> |
| | | #endif |
| | | |
| | | #include "network.h" |
| | | #include "region_layer.h" |
| | | #include "cost_layer.h" |
| | |
| | | sprintf(buff, "%s/%s_final.weights", backup_directory, base); |
| | | save_weights(net, buff); |
| | | |
| | | //cvReleaseImage(&img); |
| | | //cvDestroyAllWindows(); |
| | | #ifdef OPENCV |
| | | cvReleaseImage(&img); |
| | | cvDestroyAllWindows(); |
| | | #endif |
| | | |
| | | // free memory |
| | | pthread_join(load_thread, 0); |
| | | free_data(buffer); |
| | | |
| | | free(base); |
| | | free(paths); |
| | | free_list_contents(plist); |
| | | free_list(plist); |
| | | |
| | | free_list_contents_kvp(options); |
| | | free_list(options); |
| | | |
| | | free(nets); |
| | | free_network(net); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // free memory |
| | | free_ptrs(names, net.layers[net.n - 1].classes); |
| | | free_list_contents_kvp(options); |
| | | free_list(options); |
| | | |
| | | int i; |
| | |
| | | if (filename[strlen(filename) - 1] == 0x0d) filename[strlen(filename) - 1] = 0; |
| | | demo(cfg, weights, thresh, hier_thresh, cam_index, filename, names, classes, frame_skip, prefix, out_filename, |
| | | http_stream_port, dont_show, ext_output); |
| | | |
| | | free_list_contents_kvp(options); |
| | | free_list(options); |
| | | } |
| | | else printf(" There isn't such command: %s", argv[2]); |
| | | } |
| | |
| | | #endif |
| | | return; |
| | | } |
| | | if (l.mask) free(l.mask); |
| | | if (l.cweights) free(l.cweights); |
| | | if (l.indexes) free(l.indexes); |
| | | if (l.input_layers) free(l.input_layers); |
| | |
| | | #include <stdlib.h> |
| | | #include <string.h> |
| | | #include "list.h" |
| | | #include "option_list.h" |
| | | |
| | | list *make_list() |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | void free_list_contents_kvp(list *l) |
| | | { |
| | | node *n = l->front; |
| | | while (n) { |
| | | kvp *p = n->val; |
| | | free(p->key); |
| | | free(n->val); |
| | | n = n->next; |
| | | } |
| | | } |
| | | |
| | | void **list_to_array(list *l) |
| | | { |
| | | void **a = calloc(l->size, sizeof(void*)); |
| | |
| | | |
| | | void free_list(list *l); |
| | | void free_list_contents(list *l); |
| | | void free_list_contents_kvp(list *l); |
| | | |
| | | #endif |
| | |
| | | sprintf(buffer, "%s", str); |
| | | if(!(p = strstr(buffer, orig))){ // Is 'orig' even in 'str'? |
| | | sprintf(output, "%s", str); |
| | | free(buffer); |
| | | return; |
| | | } |
| | | |
| | |
| | | int chars_from_end = strlen(buffer) - offset; |
| | | if (!p || chars_from_end != strlen(orig)) { // Is 'orig' even in 'str' AND is 'orig' found at the end of 'str'? |
| | | sprintf(output, "%s", str); |
| | | free(buffer); |
| | | return; |
| | | } |
| | | |
| | |
| | | void replace_image_to_label(char *input_path, char *output_path) { |
| | | //find_replace(input_path, "images", "labels", output_path); // COCO |
| | | find_replace(input_path, "images/train2014/", "labels/train2014/", output_path); // COCO |
| | | find_replace(input_path, "images/val2014/", "labels/val2014/", output_path); // COCO |
| | | find_replace(output_path, "images/val2014/", "labels/val2014/", output_path); // COCO |
| | | //find_replace(output_path, "JPEGImages", "labels", output_path); // PascalVOC |
| | | find_replace(output_path, "VOC2007/JPEGImages", "VOC2007/labels", output_path); // PascalVOC |
| | | find_replace(output_path, "VOC2012/JPEGImages", "VOC2012/labels", output_path); // PascalVOC |
| | | // replace only ext of files |
| | | find_replace_extension(output_path, ".jpg", ".txt", output_path); |
| | | find_replace_extension(output_path, ".JPG", ".txt", output_path); |
| | | find_replace_extension(output_path, ".JPG", ".txt", output_path); // error |
| | | find_replace_extension(output_path, ".jpeg", ".txt", output_path); |
| | | find_replace_extension(output_path, ".JPEG", ".txt", output_path); |
| | | find_replace_extension(output_path, ".png", ".txt", output_path); |
| | |
| | | size_t offset = 0; |
| | | for(i = 0; i < len; ++i){ |
| | | char c = s[i]; |
| | | if(c==' '||c=='\t'||c=='\n'||c =='\r') ++offset; |
| | | if(c==' '||c=='\t'||c=='\n'||c =='\r'||c==0x0d||c==0x0a) ++offset; |
| | | else s[i-offset] = c; |
| | | } |
| | | s[len-offset] = '\0'; |