|
13 | 13 | import shutil |
14 | 14 | import cv2 |
15 | 15 | import random |
| 16 | +from dataset_tools import * |
16 | 17 |
|
17 | 18 |
|
18 | 19 | def sortPoints(points, label): |
@@ -200,9 +201,32 @@ def removeNolabelDatasets(root_path): |
200 | 201 | os.remove(os.path.join(root_path, GetLastDir(image_path)[:-4] + ".json")) |
201 | 202 | os.remove(image_path) |
202 | 203 | else: |
| 204 | + print("清除图片") |
203 | 205 | os.remove(image_path) |
204 | 206 | progressBar.update() |
205 | 207 |
|
| 208 | +def removeNolabelVocDatasets(root_path): |
| 209 | + for day in os.listdir(root_path): |
| 210 | + if os.path.isdir(os.path.join(root_path,day)): |
| 211 | + image_path_list = GetAllImagesPath(os.path.join(root_path, day, DIRECTORY_IMAGES)) |
| 212 | + progressBar = ProgressBar(len(image_path_list)) |
| 213 | + for image_path in image_path_list: |
| 214 | + if os.path.exists( |
| 215 | + os.path.join(root_path, day, DIRECTORY_ANNOTATIONS, GetLastDir(image_path)[:-4] + ".xml")): |
| 216 | + imagename, shape, bboxes, labels_text, labels, difficult, truncated = ProcessXml( |
| 217 | + os.path.join(root_path, day, DIRECTORY_ANNOTATIONS, GetLastDir(image_path)[:-4] + ".xml")) |
| 218 | + if len(bboxes) == 0: |
| 219 | + print("清除{},清除{}".format(image_path, os.path.join(root_path, day, DIRECTORY_ANNOTATIONS, |
| 220 | + GetLastDir(image_path)[:-4] + ".xml"))) |
| 221 | + os.remove( |
| 222 | + os.path.join(root_path, day, DIRECTORY_ANNOTATIONS, GetLastDir(image_path)[:-4] + ".xml")) |
| 223 | + os.remove(image_path) |
| 224 | + else: |
| 225 | + print("清除{}".format(image_path)) |
| 226 | + os.remove(image_path) |
| 227 | + progressBar.update() |
| 228 | + |
| 229 | + |
206 | 230 |
|
207 | 231 | def GetContaNumberPath(image_path_list): |
208 | 232 | ContaNumber_list = [] |
|
0 commit comments