def get_feature(self, index):
        if self.state == 'Normal':  # Load a normal video
            if len(self.features_list_normal) > 0:
                idx = random.randint(0, len(self.features_list_normal) - 1)
                feature_subpath = self.features_list_normal[idx].split(os.sep)

            else:  # No normal videos, load an anomalous one
                idx = random.randint(0, len(self.features_list_anomaly) - 1)
                feature_subpath = self.features_list_anomaly[idx].split(os.sep)

        elif self.state == 'Anomalous':  # Load an anomalous video
            if len(self.features_list_anomaly) > 0:
                idx = random.randint(0, len(self.features_list_anomaly) - 1)
                feature_subpath = self.features_list_anomaly[idx].split(os.sep)

            else:  # No anomalous videos, load a normal one
                idx = random.randint(0, len(self.features_list_normal) - 1)
                feature_subpath = self.features_list_normal[idx].split(os.sep)

        features = read_features(dir=os.sep.join(feature_subpath[:-1]),
                                 video_name=feature_subpath[-1])

        self.state = 'Anomalous' if self.state == 'Normal' else 'Normal'
        feature_subpath = os.sep.join(feature_subpath)
        label = 1 if "Normal" not in feature_subpath else 0

        return features, label
예제 #2
0
    def get_feature(self, index):
        feature_subpath, start_end_couples, length = self.features_list[index]
        feature_subpath = feature_subpath.split(os.sep)
        features = read_features(dir=os.sep.join(feature_subpath[:-1]),
                                 video_name=feature_subpath[-1])

        feature_subpath = os.sep.join(feature_subpath)

        vid_subpath = feature_subpath.split(os.sep)
        vid_subpath = os.sep.join(vid_subpath[-2:])

        return features, start_end_couples, vid_subpath, length
    def get_feature(self, index):
        if self.state == 'Normal':  # Load a normal video
            idx = random.randint(0, len(self.features_list_normal) - 1)
            feature_subpath = self.features_list_normal[idx]
            label = 0

        elif self.state == 'Anomalous':  # Load an anomalous video
            idx = random.randint(0, len(self.features_list_anomaly) - 1)
            feature_subpath = self.features_list_anomaly[idx]
            label = 1

        features = read_features(f"{feature_subpath}.txt")
        
        self.state = 'Anomalous' if self.state == 'Normal' else 'Normal'

        return features, label
예제 #4
0
    def get_feature(self, index):
        if self.state == 'Normal':  # load a normal video
            if len(self.features_list_normal) > 0:
                idx = random.randint(0, len(self.features_list_normal) - 1)
                feature_subpath = self.features_list_normal[idx].split(os.sep)

            else:  # no normal video, load an anomalous one
                idx = random.randint(0, len(self.features_list_anomaly) - 1)
                feature_subpath = self.features_list_anomaly[idx].split(os.sep)

        elif self.state == 'Anomalous':  # load an anomalous video
            if len(self.features_list_anomaly) > 0:
                idx = random.randint(0, len(self.features_list_anomaly) - 1)
                feature_subpath = self.features_list_anomaly[idx].split(os.sep)

            else:  # no anomalous video, load a normal one
                idx = random.randint(0, len(self.features_list_normal) - 1)
                feature_subpath = self.features_list_normal[idx].split(os.sep)

        features = read_features(dir=os.sep.join(feature_subpath[:-1]),
                                 video_name=feature_subpath[-1])
        if self.state == 'Normal':
            self.normal_i += 1
            self.state = 'Anomalous'
        elif self.state == 'Anomalous':
            self.anomalous_i += 1
            self.state = 'Normal'

        feature_subpath = os.sep.join(feature_subpath)
        if self.classid_path is None:
            if "Normal" in feature_subpath:
                label = 0
            else:
                label = 1
        else:
            label = read_label(feature_subpath, self.classid_path)

        return features, label
 def get_feature(self, index):
     feature_subpath, start_end_couples, length = self.features_list[index]
     features = read_features(f"{feature_subpath}.txt")
     return features, start_end_couples, length