Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert txt to pkl #24

Open
WellDL opened this issue Apr 28, 2020 · 2 comments
Open

Convert txt to pkl #24

WellDL opened this issue Apr 28, 2020 · 2 comments

Comments

@WellDL
Copy link

WellDL commented Apr 28, 2020

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

@quangnmkma
Copy link

quangnmkma commented Dec 9, 2022

I have the same the question :((

@luigy-mach
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants