PascalVOC label scripts are updated

pull/1311/head
AlexeyAB 7 years ago
parent 0ae1cd81d2
commit dfbec7ea2b
  1. 11
      scripts/voc_label.py
  2. 8
      scripts/voc_label_difficult.py
  3. 12
      src/yolo_v2_class.hpp

@ -10,10 +10,10 @@ classes = ["aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat"
def convert(size, box): def convert(size, box):
dw = 1./size[0] dw = 1./(size[0])
dh = 1./size[1] dh = 1./(size[1])
x = (box[0] + box[1])/2.0 x = (box[0] + box[1])/2.0 - 1
y = (box[2] + box[3])/2.0 y = (box[2] + box[3])/2.0 - 1
w = box[1] - box[0] w = box[1] - box[0]
h = box[3] - box[2] h = box[3] - box[2]
x = x*dw x = x*dw
@ -54,3 +54,6 @@ for year, image_set in sets:
convert_annotation(year, image_id) convert_annotation(year, image_id)
list_file.close() list_file.close()
os.system("cat 2007_train.txt 2007_val.txt 2012_train.txt 2012_val.txt > train.txt")
os.system("cat 2007_train.txt 2007_val.txt 2007_test.txt 2012_train.txt 2012_val.txt > train.all.txt")

@ -10,10 +10,10 @@ classes = ["aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat"
def convert(size, box): def convert(size, box):
dw = 1./size[0] dw = 1./(size[0])
dh = 1./size[1] dh = 1./(size[1])
x = (box[0] + box[1])/2.0 x = (box[0] + box[1])/2.0 - 1
y = (box[2] + box[3])/2.0 y = (box[2] + box[3])/2.0 - 1
w = box[1] - box[0] w = box[1] - box[0]
h = box[3] - box[2] h = box[3] - box[2]
x = x*dw x = x*dw

@ -97,14 +97,14 @@ public:
{ {
if (mat.data == NULL) return std::shared_ptr<image_t>(NULL); if (mat.data == NULL) return std::shared_ptr<image_t>(NULL);
cv::Size s = mat.size(); cv::Size network_size = cv::Size(get_net_width(), get_net_height());
if (get_net_width() != s.width || get_net_height() != s.height) {
cv::Mat det_mat; cv::Mat det_mat;
cv::resize(mat, det_mat, cv::Size(get_net_width(), get_net_height())); if (mat.size() != network_size)
return mat_to_image(det_mat); cv::resize(mat, det_mat, network_size);
} else
det_mat = mat; // only reference is copied
return mat_to_image(mat); return mat_to_image(det_mat);
} }
static std::shared_ptr<image_t> mat_to_image(cv::Mat img_src) static std::shared_ptr<image_t> mat_to_image(cv::Mat img_src)

Loading…
Cancel
Save