Train Validation data split - labels available but no classes

前端 未结 1 1220
刺人心
刺人心 2021-01-27 05:03

my studies project is to develop a neural network to recognize text on license plates. Therefore, I found the ReId-dataset at https://medusa.fit.vutbr.cz/traffic/research-topics

1条回答
  •  孤独总比滥情好
    2021-01-27 05:32

    Question 1 and 2:

    For reading the images, imread from matplotlib.pyplot can be used as shown in the example, this does not require any classes to be set.

    Question 3:

    The labels and images can be brought together by storing the corresponding license plate number in an output array (y in the example) for each image (stored in the xs array in the example) in the data array. You don't necessarily need to merge them.

    Hope I helped!

    import os
    import matplotlib.pyplot as plt
    import numpy as np 
    import pandas as pd
    
    xs, y = [], []
    main_dir = './sample/dataset' # the main directory 
    label_data = pd.read_csv('labels.csv')
    
    for folder in os.listdir(main_dir):
        for img in os.listdir(os.path.join(main, folder)):
            arr = plt.imread(os.path.join(main, folder) + img)
            xs.append(arr)
            y.append(label_data[label_data['image_path'] == os.path.join(folder, img)]['lp'])
                    #^ this part can be changed depending on the exact format of your label data file.
    
    # then you can convert them into numpy arrays and reshape them as you need.
    xs = np.array(xs)
    y = np.array(y)
    

    0 讨论(0)
提交回复
热议问题