first commit
This commit is contained in:
1 parent
ae53e9eac5
commit
91cbd01126
514 files changed
+55625
-2203
No files matched your search
Regular → Executable
+24
-14
@@ -1,30 +1,40 @@
|
||||
import os,argparse,torch
|
||||
from System_I import Detection_Y5
|
||||
from System_I import Detection_Y5,Fine_grained_T
|
||||
from tqdm import tqdm
|
||||
|
||||
|
||||
#os.environ['CUDA_VISIBLE_DEVICES'] = "1"
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser1 = argparse.ArgumentParser(description="AILabel")
|
||||
parser1.add_argument("--RawPath", default='/data/DataManagement/Project/001_cuihu/0012_20220517_RTSP/imagesAILabel', type=str,
|
||||
parser1.add_argument("--RawPath", default='/data/DataManagement/Project/006_huanghekou/0006_20220621/Raw_images/imagesAILabel', type=str,
|
||||
help='RawPath.')
|
||||
parser1.add_argument("--GPU", default="1", type=str,
|
||||
parser1.add_argument("--GPU", default="4", type=str,
|
||||
help='GPU.')
|
||||
parser1.add_argument("--thresh", default=0.4, type=float,
|
||||
help='thresh.')
|
||||
parser1.add_argument("--Weight", default="/data/Hatcher/data/Detection_weigth/BJCHKMCH-Bird-1-4/weights/best.pt", type=str,
|
||||
help='Weight.')
|
||||
args = parser1.parse_args()
|
||||
os.environ['CUDA_VISIBLE_DEVICES'] = args.GPU
|
||||
devices = torch.device('cuda:{}'.format(str(int(args.GPU))) if torch.cuda.is_available() else 'cpu')
|
||||
os.environ['CUDA_VISIBLE_DEVICES'] = args.GPU#"1"
|
||||
try:
|
||||
if "imagesAILabel" not in args.RawPath:
|
||||
exit()
|
||||
else:
|
||||
os.system("sudo chmod 777 -R {}".format(str(args.RawPath).replace("imagesAILabel","")))
|
||||
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')
|
||||
if not os.path.exists(args.RawPath.replace("imagesAILabel","NoResult")):
|
||||
os.makedirs(args.RawPath.replace("imagesAILabel","NoResult"))
|
||||
if not os.path.exists(args.RawPath.replace("imagesAILabel","YesResult")):
|
||||
os.makedirs(args.RawPath.replace("imagesAILabel","YesResult"))
|
||||
if not os.path.exists(args.RawPath.replace("imagesAILabel","LabelXML")):
|
||||
os.makedirs(args.RawPath.replace("imagesAILabel","LabelXML"))
|
||||
Detection = Detection_Y5(device=devices,root=" ", detect_thresh=args.thresh,DetWeight=args.Weight)
|
||||
if not os.path.exists(args.RawPath.replace("imagesAILabel","JPEGImages")):
|
||||
os.makedirs(args.RawPath.replace("imagesAILabel","JPEGImages"))
|
||||
if not os.path.exists(args.RawPath.replace("imagesAILabel","Annotations")):
|
||||
os.makedirs(args.RawPath.replace("imagesAILabel","Annotations"))
|
||||
if not os.path.exists(args.RawPath.replace("imagesAILabel", "BrokenImage")):
|
||||
os.makedirs(args.RawPath.replace("imagesAILabel", "BrokenImage"))
|
||||
|
||||
Detection = Detection_Y5(device=devices,root=" ", detect_thresh=args.thresh)
|
||||
FineGrained = Fine_grained_T(device=devices)
|
||||
imagepaths = os.listdir(args.RawPath)
|
||||
for imagepath in tqdm(imagepaths):
|
||||
imagepath = os.path.join(args.RawPath,imagepath)
|
||||
Detection.AIlabel(imagepath)
|
||||
Detection.AIlabelFine(imagepath,FineGrained)
|
||||
Reference in new issue
Block a user