From b36512ea2e7e6d2ec36a3241c1bf751e4e074fe1 Mon Sep 17 00:00:00 2001
From: vinjn <vinjn.z@gmail.com>
Date: Sat, 26 May 2018 13:42:53 +0000
Subject: [PATCH] classifier.c - add the awesome training chart and make sure "top" is not bigger than "classes" in datacfg file.

---
 src/data.c |   29 ++++++++---------------------
 1 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/src/data.c b/src/data.c
index 3b014b4..a429862 100644
--- a/src/data.c
+++ b/src/data.c
@@ -137,7 +137,10 @@
 {
     box_label *boxes = calloc(1, sizeof(box_label));
     FILE *file = fopen(filename, "r");
-    if(!file) file_error(filename);
+	if (!file) {
+		printf("Can't open label file. \n");
+		file_error(filename);
+	}
     float x, y, h, w;
     int id;
     int count = 0;
@@ -210,11 +213,7 @@
 void fill_truth_swag(char *path, float *truth, int classes, int flip, float dx, float dy, float sx, float sy)
 {
     char labelpath[4096];
-    find_replace(path, "images", "labels", labelpath);
-    find_replace(labelpath, "JPEGImages", "labels", labelpath);
-    find_replace(labelpath, ".jpg", ".txt", labelpath);
-    find_replace(labelpath, ".JPG", ".txt", labelpath);
-    find_replace(labelpath, ".JPEG", ".txt", labelpath);
+	replace_image_to_label(path, labelpath);
 
     int count = 0;
     box_label *boxes = read_boxes(labelpath, &count);
@@ -248,14 +247,9 @@
 void fill_truth_region(char *path, float *truth, int classes, int num_boxes, int flip, float dx, float dy, float sx, float sy)
 {
     char labelpath[4096];
-    find_replace(path, "images", "labels", labelpath);
-    find_replace(labelpath, "JPEGImages", "labels", labelpath);
+	replace_image_to_label(path, labelpath);
 
-    find_replace(labelpath, ".jpg", ".txt", labelpath);
-    find_replace(labelpath, ".png", ".txt", labelpath);
-    find_replace(labelpath, ".JPG", ".txt", labelpath);
-    find_replace(labelpath, ".JPEG", ".txt", labelpath);
-    int count = 0;
+	int count = 0;
     box_label *boxes = read_boxes(labelpath, &count);
     randomize_boxes(boxes, count);
     correct_boxes(boxes, count, dx, dy, sx, sy, flip);
@@ -297,15 +291,8 @@
 	int small_object, int net_w, int net_h)
 {
     char labelpath[4096];
-    find_replace(path, "images", "labels", labelpath);
-    find_replace(labelpath, "JPEGImages", "labels", labelpath);
+	replace_image_to_label(path, labelpath);
 
-    find_replace(labelpath, "raw", "labels", labelpath);
-    find_replace(labelpath, ".jpg", ".txt", labelpath);
-    find_replace(labelpath, ".png", ".txt", labelpath);
-	find_replace(labelpath, ".bmp", ".txt", labelpath);
-    find_replace(labelpath, ".JPG", ".txt", labelpath);
-    find_replace(labelpath, ".JPEG", ".txt", labelpath);
     int count = 0;
 	int i;
     box_label *boxes = read_boxes(labelpath, &count);

--
Gitblit v1.10.0