TALLFormer icon indicating copy to clipboard operation
TALLFormer copied to clipboard

Code to Visualize Inference output

Open chethanluffy opened this issue 2 years ago • 3 comments

Thank you for you excellent work! I have a question regarding the output data format. Could you kindly explain the output data format which is being saved as pickle file at the end of the Inference(tools/test.py). And is there script to visualize Inference output? Thanks

chethanluffy avatar Nov 09 '22 06:11 chethanluffy

Hello, do you know what the content in the output file (results_ex-chunk.pkl) means now, and how to view the performance of the model on the dataset, such as [email protected], [email protected] etc. Thanks!

LIUQI-creat avatar Nov 24 '22 03:11 LIUQI-creat

add these lines inplace of for loop in "tools/test.py" to get output predictions as CSV file. You will understand the output once you open the CSV file.

resultsDf = pd.DataFrame()   #### Writing RESULTS to CSV
csvPath = args.out
csvPath = csvPath.replace('.pkl','.csv')
for i, data in enumerate(data_loader):
    fileName = data['video_metas'][0]._data[0][0]['ori_video_name']
    nFrames = data['video_metas'][0]._data[0][0]['ori_tsize']
    print("FileName: ", fileName)
    with torch.no_grad():
        result = engine(data)[0]
    #### Writing RESULTS to CSV
    for classID, eaclClassResult in enumerate(result):
        tempDf = pd.DataFrame(eaclClassResult, columns = ['sFrame','eFrame','classScore'])
        tempDf['nFrames'] = nFrames
        tempDf['class'] = classID
        tempDf['file'] = fileName
        if classID == 0 and i == 0:
            resultsDf = tempDf.copy()
            resultsDf.to_csv(csvPath, index=False) #### Writing RESULTS to CSV
        else:
            resultsDf = pd.concat([tempDf, resultsDf], ignore_index=True)
            resultsDf.to_csv(csvPath, index=False) #### Writing RESULTS to CSV
    print(resultsDf.shape)
    #### Writing RESULTS to CSV
    results.append(result)
    batch_size = len(data["video_metas"][0].data)
    for _ in range(batch_size):
        prog_bar.update()
print("CSV file saved @ : ", csvPath)
resultsDf.to_csv(csvPath, index=False) #### Writing RESULTS to CSV

chethanluffy avatar Dec 01 '22 18:12 chethanluffy

Thank you very much, I will try it.

LIUQI-creat avatar Dec 02 '22 08:12 LIUQI-creat