# -*- coding: utf-8  -*-
# -*- author: jokker -*-

import os
import random
from JoTools.utils.FileOperationUtil import FileOperationUtil

img_dir = r"D:\data\001_fzc_优化相关资料\dataset_fzc\001_train_data_step_1.5\jieya\zd"
save_dir = r"C:\Users\14271\Desktop\train_vit\3"

# for each_img_path in FileOperationUtil.re_all_file(img_dir, endswitch=['.jpg', '.JPG']):
#
#     random_num = random.randrange(1, 1000)
#
#     print(random_num)
#
#     if random_num > 250:
#         os.remove(each_img_path)

img_path_list = list(
    FileOperationUtil.re_all_file(img_dir, endswitch=['.jpg', '.JPG']))

FileOperationUtil.move_file_to_folder(img_path_list, save_dir, is_clicp=True)
Ejemplo n.º 2
0
index = 0
for each_xml_path in FileOperationUtil.re_all_file(xml_dir, endswitch=['.xml']):

    index += 1
    print(index, each_xml_path)

    xml_name = os.path.split(each_xml_path)[1]
    img_name = xml_name[:-3] + 'jpg'
    each_img_path = os.path.join(img_dir, img_name)

    if not (os.path.exists(each_xml_path) and os.path.exists(each_img_path)):
        print("* 没找到对应的 img 数据: {0}".format(each_img_path))
        continue

    a = DeteRes(each_xml_path)

    # a.filter_by_area(50*100)

    if len(a) < 1:
        continue

    img_path_list.append(each_img_path)
    xml_path_list.append(each_xml_path)

FileOperationUtil.move_file_to_folder(img_path_list, img_save_dir, is_clicp=False)
FileOperationUtil.move_file_to_folder(xml_path_list, xml_save_dir, is_clicp=False)



# -*- coding: utf-8  -*-
# -*- author: jokker -*-


from JoTools.utils.FileOperationUtil import FileOperationUtil


assign_dir = r"\\192.168.3.80\大金具-算法\qfm\连接件训练数据集"
save_dir = r"C:\Users\14271\Desktop\连接件"


FileOperationUtil.move_file_to_folder(FileOperationUtil.re_all_file(assign_dir, endswitch=['.xml']), save_dir, is_clicp=False)



config_path = r"D:\Algo\saturn_database\config.ini"

Ejemplo n.º 4
0
    each_xml_path = os.path.join(
        new_xml_dir,
        FileOperationUtil.bang_path(each_img_path)[1] + '.xml')
    #
    each_new_img_path = os.path.join(region_img_dir,
                                     os.path.split(each_img_path)[1])
    each_new_xml_path = os.path.join(region_xml_dir,
                                     os.path.split(each_xml_path)[1])

    if os.path.exists(each_new_img_path):
        print("* img path exists : {0}".format(each_new_img_path))
        continue

    if os.path.exists(each_new_xml_path):
        print("* xml path exists : {0}".format(each_new_xml_path))
        continue

    new_img_path_list.append(each_img_path)
    new_xml_path_list.append(each_xml_path)

PrintUtil.print(new_img_path_list)
print('-' * 30)
PrintUtil.print(new_xml_path_list)

FileOperationUtil.move_file_to_folder(new_img_path_list,
                                      region_img_dir,
                                      is_clicp=True)
FileOperationUtil.move_file_to_folder(new_xml_path_list,
                                      region_xml_dir,
                                      is_clicp=True)