imageaiの概要と使い方
概要
- GitHub
- 画像系、映像系のディープラーニングをかんたんに使えるようにしたもの
動画の物体認識(video object detection)の推論
from imageai.Detection import VideoObjectDetection
import os
execution_path = os.getcwd()
detector = VideoObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath(os.path.join(execution_path, "resnet50_coco_best_v2.1.0.h5"))
detector.loadModel()
def forSeconds(second_number, output_arrays, count_arrays, average_output_count):
print("SECOND : ", second_number)
print("Array for the outputs of each frame ", output_arrays)
print("Array for output count for unique objects in each frame : ", count_arrays)
print("Output average count for unique objects in the last second: ", average_output_count)
print("------------END OF A SECOND --------------")
video_path = detector.detectCustomObjectsFromVideo(
input_file_path=os.path.join(execution_path, "test.mp4"),
output_file_path=os.path.join(execution_path, "tdetected"),
frames_per_second=1,
per_second_function=forSeconds,
minimum_percentage_probability=30,
log_progress=True,
)
- mp4の動画を毎秒何がどこに写っているかを推論する
- fileの書き出し等と併用すれば、videoの統計情報を作成することが可能