def __init__(self, models=list(), total_norm_weights=None, score_name='fc-action', dev_id=0): """ Contruct an action classifier Args: models: list of tuples in the form of (model_proto, model_params, model_fusion_weight, input_type, conv_support, input_size). input_type is: 0-RGB, 1-Optical flow. conv_support indicates whether the network supports convolution testing, which is faster. If this is not supported, we will use oversampling instead total_norm_weights: sum of all model_fusion_weights when normalization is wanted, otherwise use None """ self.__net_vec = [ CaffeNet(x[0], x[1], dev_id, input_size=(340, 256) if x[4] else None) for x in models ] self.__net_weights = [float(x[2]) for x in models] if total_norm_weights is not None: s = sum(self.__net_weights) self.__net_weights = [x / s for x in self.__net_weights] self.__input_type = [x[3] for x in models] self.__conv_support = [x[4] for x in models] self.__num_net = len(models) # the input size of the network self.__input_size = [x[5] for x in models] # whether we should prepare flow stack self.__need_flow = max(self.__input_type) > 0 # the name in the proto for action classes self.__score_name = score_name # the video downloader #self.__video_dl = youtube_dl.YoutubeDL( # { # 'outtmpl': '%(id)s.%(ext)s' # } #) if self.__need_flow: self.__flow_extractor = FlowExtractor(dev_id)