Datasets:

Modalities:
Image
Formats:
parquet
Languages:
English
DOI:
Libraries:
Datasets
Dask
License:
File size: 1,345 Bytes
ae6e9e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/env python3

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)