Avenue
import sys
sys.path.append('..')
from pysauron.datasets import Avenue
from pysauron.transforms import RandomAnomalyInject, ChangeDirection, FrameDrop
import matplotlib.pyplot as plt
from IPython.display import clear_output
train_dataset = Avenue(root='../data/AvenueDataset/', test_mode=False, _debug=True)
test_dataset = Avenue(root='../data/AvenueDataset/', test_mode=True, _debug=True)
print('# Train samples: ', len(train_dataset))
print('# Test samples: ', len(test_dataset))
sample = test_dataset[75]
for i in range(sample[0].shape[0]):
plt.imshow(sample[0][i])
plt.imshow(sample[1][i], alpha=0.5)
plt.title(f'Label: {sample[2][i]}')
clear_output(True)
plt.show()
print('Sample temporal labels: ', sample[2])
Frame drop augmentation¤
sample = test_dataset[75]
video, label, temporal_l = FrameDrop(k=9, always_apply=True)(video=sample[0], label=sample[1], temporal_label=sample[2])
for i in range(video.shape[0]):
plt.imshow(video[i])
plt.imshow(label[i], alpha=0.5)
plt.title(f'Label: {temporal_l[i]}')
clear_output(True)
plt.show()
print('Sample temporal labels after transform: ', temporal_l)
Direction change augmentation¤
sample = test_dataset[75]
video, label, temporal_l = ChangeDirection(always_apply=True)(video=sample[0], label=sample[1], temporal_label=sample[2])
for i in range(video.shape[0]):
plt.imshow(video[i])
plt.imshow(label[i], alpha=0.5)
plt.title(f'Label: {temporal_l[i]}')
clear_output(True)
plt.show()
print('Sample temporal labels after transform: ', temporal_l)
Randomg injection augmentation¤
sample = test_dataset[75]
video, label, temporal_l = RandomAnomalyInject(
anomaly_folder='/Users/bogdanivanyuk/Desktop/PySauron/pysauron/transforms/assets/anomalies/animals',
always_apply=True)(video=sample[0], label=sample[1], temporal_label=sample[2])
for i in range(video.shape[0]):
plt.imshow(video[i])
plt.imshow(label[i], alpha=0.5)
plt.title(f'Label: {temporal_l[i]}')
clear_output(True)
plt.show()
print('Sample temporal labels after transform: ', temporal_l)