Skip to content

Commit e3954ea

Browse files
authored
Update train_engine.py
1 parent 4ff406c commit e3954ea

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

19_pytorch_textsnake/lib/train_engine.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import scipy.io as io
55
import numpy as np
66
from tqdm import tqdm
7+
import cv2
78

89
import json
910
import torch
@@ -271,7 +272,13 @@ def Convert_Json_To_Txt(self, img_folder=None, json_anno_file=None, output_anno_
271272
img_name = complete_img_name_list[i];
272273

273274
if(len(anno) > 0):
274-
os.system("cp " + img_folder + "/" + img_name + " " + output_img_folder + "/");
275+
img = cv2.imread(img_folder + "/" + img_name);
276+
try:
277+
h, w, c = img.shape
278+
except:
279+
img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB);
280+
cv2.imwrite(output_img_folder + "/" + img_name, img);
281+
275282
anno_file = output_anno_folder + "/" + img_name.split(".")[0] + ".txt";
276283
f = open(anno_file, 'w');
277284
#print(anno, os.path.isfile("train2014/" + img_name))

0 commit comments

Comments
 (0)