ekosman / AnomalyDetectionCVPR2018-Pytorch

Pytorch version of - https://github.com/WaqasSultani/AnomalyDetectionCVPR2018
176 stars 55 forks source link

FeaturesLoader #62

Closed huitailangdeerzi closed 3 years ago

huitailangdeerzi commented 3 years ago

class FeaturesLoader(data.Dataset): def init(self, features_path, annotation_path, bucket_size=30):

    super(FeaturesLoader, self).__init__()
    self.features_path = features_path
    self.bucket_size = bucket_size
    # load video list
    self.state = 'Normal'
    self.features_list_normal, self.features_list_anomaly = FeaturesLoader._get_features_list(
        features_path=self.features_path,
        annotation_path=annotation_path)

    self.normal_i, self.anomalous_i = 0, 0

    self.shuffle()

def shuffle(self):
    self.features_list_anomaly = np.random.permutation(self.features_list_anomaly)
    self.features_list_normal = np.random.permutation(self.features_list_normal)

def __len__(self):
    return self.bucket_size * 2

您好我想问一下,def len(self):这一块为什么设置bucket_size,为什么不def len(self): return len( self.features_list_normal)*2

RachanaAgarwal commented 3 years ago

Or rather return len(self.features_list_normal) + len(self.features_list_anomaly )

ekosman commented 3 years ago

@huitailangdeerzi @RachanaAgarwal In my implementation, each epoch represents one iteration as described in the original paper consisting of two buckets - one for normal videos and the other for anomalous videos. Thus, the length of the iterator is set to be twice the bucket size, which is 30 in the original paper.