first commit

This commit is contained in:
hatcher committed 2026-07-17 18:55:31 +08:00
1 parent ae53e9eac5
commit 91cbd01126
514 files changed
+55625 -2203

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
import os,argparse,torch
from System_I import Detection_Y5,Fine_grained_T,Fine_grained_mmclsonnx
from tqdm import tqdm
#os.environ['CUDA_VISIBLE_DEVICES'] = "1"
"""###
输入:/根目录/imagesAI
-------文件夹1
------NoResult 存放无结果图片
------BrokenImage 存放损坏图片
------imagesAILabel 存放待处理图片
------Annotations 存放识别结果xml标签文件
------JPEGImages 备份原图原图
------result 存放可视化结果图片
-------文件夹2
------NoResult 存放无结果图片
------BrokenImage 存放损坏图片
------imagesAILabel 存放待处理图片
------Annotations 存放识别结果xml标签文件
------JPEGImages 备份原图原图
------result 存放可视化结果图片
###"""
if __name__ == '__main__':
parser1 = argparse.ArgumentParser(description="AILabel")
parser1.add_argument("--RawPath", default='/data5/student/Hatcher/test/imagesAI', type=str,
help='RawPath.')
parser1.add_argument("--GPU", default="2", type=str,
help='GPU.') #本参数在该工程中不起作用,请修改common.py文件种的全局参数
parser1.add_argument("--thresh", default=0.4, type=float,
help='thresh.')
args = parser1.parse_args()
os.environ['CUDA_VISIBLE_DEVICES'] = args.GPU#"1"
try:
if "imagesAI" not in args.RawPath:
exit()
else:
os.system("sudo chmod 777 -R {}".format(str(args.RawPath).replace("imagesAI","")))
except:
exit()
#devices = torch.device('cuda:{}'.format(str(int(args.GPU))) if torch.cuda.is_available() else 'cpu')
devices = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
Detection = Detection_Y5(device=devices, root=" ", detect_thresh=args.thresh)
FineGrained = Fine_grained_mmclsonnx(device=devices)
for RawPaths in os.listdir(args.RawPath):
RawPath = os.path.join(args.RawPath,RawPaths,"imagesAILabel")
if not os.path.exists(RawPath.replace("imagesAILabel","NoResult")):
os.makedirs(RawPath.replace("imagesAILabel","NoResult"))
if not os.path.exists(RawPath.replace("imagesAILabel","JPEGImages")):
os.makedirs(RawPath.replace("imagesAILabel","JPEGImages"))
if not os.path.exists(RawPath.replace("imagesAILabel","Annotations")):
os.makedirs(RawPath.replace("imagesAILabel","Annotations"))
if not os.path.exists(RawPath.replace("imagesAILabel", "BrokenImage")):
os.makedirs(RawPath.replace("imagesAILabel", "BrokenImage"))
if not os.path.exists(RawPath.replace("imagesAILabel", "result")):
os.makedirs(RawPath.replace("imagesAILabel", "result"))
imagepaths = os.listdir(RawPath)
for imagepath in tqdm(imagepaths):
imagepath = os.path.join(RawPath,imagepath)
Detection.AIlabelFine(imagepath,FineGrained)