| | |
| |
|
| | import json |
| | import glob |
| | import os |
| | import pandas as pd |
| | import argparse |
| |
|
| | def main(label_path): |
| | unwanted = [ |
| | 'parent_prediction', 'parent_annotation', |
| | 'last_created_by', 'completed_by', |
| | 'created_username', 'created_ago', |
| | 'project', 'updated_by', |
| | 'file_upload', 'comment_authors', 'meta', |
| | 'unresolved_comment_count', 'last_comment_updated_at', |
| | 'project', 'updated_by', |
| | 'file_upload', 'comment_authors', 'created_at', 'updated_at', 'is_labeled', |
| | 'inner_id', 'total_annotations', 'cancelled_annotations', 'total_predictions', 'comment_count'] |
| | label_files = [p for p in glob.glob(os.path.join(label_path, "*"))] |
| | label_csv = [] |
| | for l in label_files: |
| | with open(l) as label: |
| | label = json.load(label) |
| | for k in unwanted: |
| | label.pop(k, None) |
| | label['task'].pop(k, None) |
| | label_csv.append(label) |
| | label_csv = pd.DataFrame(label_csv) |
| | label_csv = label_csv.drop(columns=['draft_created_at', 'lead_time', 'last_action'], errors='ignore') |
| |
|
| | label_csv.to_csv('labels.csv') |
| |
|
| | if __name__ == "__main__": |
| | parser = argparse.ArgumentParser("labelconvertor") |
| | parser.add_argument("label_path", type=str) |
| | arguments = parser.parse_args() |
| | main(arguments.label_path) |
| |
|