Describe the bug
In the Jupyter notebook, the cell that predicts pupil size for the whole video has these lines:
# Append to list instead of DataFrame
data.append({
'frameN': int(i+1),
'pupilSize': np.sum(morphedMask)/255,
'pupCntr_x': centroid[1],
'pupCntr_y': centroid[0],
'eyeProb': eyeProbability,
'blinkProb': blinkProbability
})
However, df.append is depreciated in newer versions of pandas so this throws an error. Instead, this information could be added to a list, then a dataframe can be created from the list? Or the docker/readme could be updated to reflect that the older version of pandas is needed.
To Reproduce
Steps to reproduce the behavior: run the pre-trained model on the jupyter notebook.
Expected behavior
An error that append does not work with data frames.
Fix
The following will fix the cell:
cap = cv.VideoCapture(VIDEOPATH)
numFrames = int(cap.get(cv.CAP_PROP_FRAME_COUNT))
# df = pd.DataFrame(columns=['frameN','pupilSize','pupCntr_x','pupCntr_y','eyeProb','blinkProb'])
# Create empty list to collect data
data = []
try:
for i in range(numFrames):
_, frame = cap.read()
frame = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
croppedFrame = cropResize(frame)
if INVERTIMAGE:
croppedFrame = cv.bitwise_not(croppedFrame)
networkInput = croppedFrame.astype(np.float32) / 255.0
networkInput = networkInput[None, :, :, None]
mask, info = model(networkInput)
prediction = mask[0,:,:,0]
morphedMask, centroid = morphProcessing(prediction)
# Extract infos
eyeProbability = info[0,0]
blinkProbability = info[0,1]
# Append to list instead of DataFrame
data.append({
'frameN': int(i+1),
'pupilSize': np.sum(morphedMask)/255,
'pupCntr_x': centroid[1],
'pupCntr_y': centroid[0],
'eyeProb': eyeProbability,
'blinkProb': blinkProbability
})
if (i!=0) & (i%400==0) :
print('Processing frames... ({}/{})'.format(i,numFrames))
finally:
cap.release()
# winsound.Beep(BEEP_FREQ, BEEP_DURATION_MS)
# Create DataFrame from list (after loop completes)
df = pd.DataFrame(data)
Describe the bug
In the Jupyter notebook, the cell that predicts pupil size for the whole video has these lines:
However, df.append is depreciated in newer versions of pandas so this throws an error. Instead, this information could be added to a list, then a dataframe can be created from the list? Or the docker/readme could be updated to reflect that the older version of pandas is needed.
To Reproduce
Steps to reproduce the behavior: run the pre-trained model on the jupyter notebook.
Expected behavior
An error that append does not work with data frames.
Fix
The following will fix the cell: