1 Star 0 Fork 0

Cheng_Loon/AbnormalEventDetection

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test_detect.py 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
ShreyasArthur 提交于 2020-03-25 22:44 . Add files via upload
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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Cheng_Loon/AbnormalEventDetection.git
git@gitee.com:Cheng_Loon/AbnormalEventDetection.git
Cheng_Loon
AbnormalEventDetection
AbnormalEventDetection
master

搜索帮助