delete the image which has no labels , coco2017

 

 

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import shutil

image_root = "./train2017"
label_root = "./labels"
no_label = "./no_label"

image_list = os.listdir(image_root)
label_list = os.listdir(label_root)

for item_jpg in image_list:
    item_label = item_jpg.replace("jpg", "txt")
    if item_label in label_list:
        continue
    else:
        shutil.move(os.path.join(image_root, item_jpg), os.path.join(no_label, item_jpg))

 

posted on 2020-06-05 17:20  cdekelon  阅读(66)  评论(0)    收藏  举报

导航