代码拉取完成,页面将自动刷新
import os
from c3d import *
from classifier import *
from utils.visualization_util import *
def run_demo():
video_name = os.path.basename(cfg.sample_video_path).split('.')[0]
# read video
video_clips, num_frames = get_video_clips(cfg.sample_video_path)
print("Number of clips in the video : ", len(video_clips))
# build models
feature_extractor = c3d_feature_extractor()
classifier_model = build_classifier_model()
print("Models initialized")
# extract features
rgb_features = []
for i, clip in enumerate(video_clips):
clip = np.array(clip)
if len(clip) < params.frame_count:
continue
clip = preprocess_input(clip)
rgb_feature = feature_extractor.predict(clip)[0]
rgb_features.append(rgb_feature)
print("Processed clip : ", i)
rgb_features = np.array(rgb_features)
# bag features
rgb_feature_bag = interpolate(rgb_features, params.features_per_bag)
# classify using the trained classifier model
predictions = classifier_model.predict(rgb_feature_bag)
predictions = np.array(predictions).squeeze()
predictions = extrapolate(predictions, num_frames)
save_path = os.path.join(cfg.output_folder, video_name + '.gif')
# visualize predictions
print('Executed Successfully - '+video_name + '.gif saved')
visualize_predictions(cfg.sample_video_path, predictions, save_path)
if __name__ == '__main__':
run_demo()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。