parser.add_argument( "--no_object_folder", type=str, default=no_object_Folder, help= "Absolute path to a folder containing images that have no annotations. Default is " + no_object_Folder) FLAGS = parser.parse_args() #Prepare the dataset for YOLO multi_df = pd.read_csv(FLAGS.VoTT_csv) labels = multi_df['label'].unique() labeldict = dict(zip(labels, range(len(labels)))) multi_df.drop_duplicates(subset=None, keep='first', inplace=True) train_path = FLAGS.VoTT_Folder convert_vott_csv_to_yolo(multi_df, labeldict, path=train_path, target_name=FLAGS.YOLO_filename, zeroAnnotationPath=FLAGS.no_object_folder) # Make classes file file = open(classes_filename, "w") #Sort Dict by Values SortedLabelDict = sorted(labeldict.items(), key=lambda x: x[1]) for elem in SortedLabelDict: file.write(elem[0] + '\n') file.close()
parser.add_argument( "--YOLO_filename", type=str, default=YOLO_filename, help= "Absolute path to the file where the labels in YOLO format should be saved. Default is " + YOLO_filename, ) FLAGS = parser.parse_args() # Prepare the dataset for YOLO multi_df = pd.read_csv(FLAGS.VoTT_csv) labels = multi_df["label"].unique() labeldict = dict(zip(labels, range(len(labels)))) multi_df.drop_duplicates(subset=None, keep="first", inplace=True) train_path = FLAGS.VoTT_Folder convert_vott_csv_to_yolo(multi_df, labeldict, path=train_path, target_name=FLAGS.YOLO_filename) # Make classes file file = open(classes_filename, "w") # Sort Dict by Values SortedLabelDict = sorted(labeldict.items(), key=lambda x: x[1]) for elem in SortedLabelDict: file.write(elem[0] + "\n") file.close()
df_csv["code"].astype(int).values) if FLAGS.AWS: df_csv["image_path"] = ChangeToOtherMachine( df_csv["image_path"].values, remote_machine=AWS_path) df_csv.to_csv(CSV_filename, index=False) # Get label names and sort if FLAGS.drop_classes: df_csv = df_csv[df_csv["label"].isin(["door", "window", "shop"])] codes = df_csv["code"].unique() df_csv["code"] = df_csv["code"].apply( lambda x: np.where(codes == x)[0][0]) if FLAGS.single_class: df_csv["code"] = 0 df_csv["label"] = "opening" df_csv.to_csv("est.csv") sorted_names = ((df_csv.drop_duplicates(subset=["code", "label"])[[ "code", "label" ]].sort_values(by=["code"]))["label"]).values # Write sorted names to file to make classes file with open(classes_filename, "w") as f: for name in sorted_names[:-1]: f.write("%s\n" % name) f.write("%s" % sorted_names[-1]) # Convert Vott csv format to YOLO format convert_vott_csv_to_yolo(df_csv, abs_path=True, target_name=FLAGS.YOLO_filename)