Skip to content

Convert txt to pkl #24

Open
Open

Description

@WellDL

I am not familiar to python, however this approach seems to be great for the type augmentations I need.
Since it is necessary to use pickle format, how can I change my txt file, which order is
classes x1 x2 y1 y2

to pickle format, which order needs to be the following?
x1 y1 x2 y2 classes

Activity

  1. quangnmkma commented on Dec 9, 2022

    @quangnmkma

    I have the same the question :((

  2. luigy-mach commented on Dec 12, 2022

    @luigy-mach

    In file quick-start.ipynb comment the next lines as follows:

    # bboxes = pkl.load(open("messi_ann.pkl", "rb"))
    # #inspect the bounding boxes
    # print(bboxes)
    

    And, add the next lines:

    in_coor  = ['class','x1','y1','x2','y2'] # how in your file was sorted.
    out_coor = ['x1','y1','x2','y2','class'] # how it was requested by algorithm.
    filetxt  = 'yourfile.txt' # path of your file txt 
    with open(filetxt) as f:
        contents = f.readlines()
        
    data = list()
    for i in contents:
        data.append([float(j) for j in i.split(',')])
    
    data_arr  = np.asarray(data)
    in_order  = {j:i for i,j in enumerate(in_coor)}
    sort_in   = [in_order[k] for k in in_coor]
    sort_out  = [in_order[k] for k in out_coor]
    
    bboxes = data_arr[:,sort_out]
    #inspect the bounding boxes
    
    print(bboxes)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions