跳转到主要内容

一个用于从视频中提取最迷人的图像的库和命令

项目描述

Smiler

这是一个库和CLI工具,用于从人物的视频中提取“最迷人”的帧。

它是作为Choirless项目的一部分开发的,作为IBM Call for code项目的一部分。

安装

% pip install choirless_smiler

用法

简单用法

% smiler video.mp4 snapshot.jpg

Output image of people singing

它将进行预扫描以确定与前一个帧相比变化最大的5%帧,以便仅考虑它们。如果您知道要使用的阈值,可以使用它。例如。

smiler第一次运行时,将下载面部特征数据并将其存储在~/.smiler位置,数据路径和缓存目录可以指定为参数

% smiler video.mp4 snapshot.jpg --threshold 480000

帮助

% smiler -h
usage: smiler [-h] [--verbose] [--threshold THRESHOLD]
              [--landmarks-url LANDMARKS_URL] [--cache-dir CACHE_DIR]
              [--quantile QUANTILE]
              video_fn image_fn

Save thumbnail of smiliest frame in video

positional arguments:
  video_fn              filename for video to analyse
  image_fn              filename for output thumbnail

optional arguments:
  -h, --help            show this help message and exit
  --verbose             verbose mode
  --threshold THRESHOLD
                        threshold of difference overwhich we analyse an image
  --landmarks-url LANDMARKS_URL
                        url of facial landmark file
  --cache-dir CACHE_DIR
                        local cache to store the landmark file in
  --quantile QUANTILE   quantile of images to analyse

详细模式

如果您指定CLI中的--verbose标志,则smiler将在进行过程中打印进度条,以显示其正在做什么。

作为库使用

Smiler可以导入并在库中使用。您负责提供面部特征数据和模型的路径,但模块中的帮助函数可以帮助。

from choirless_smiler.smiler import Smiler, load_landmarks

landmarks_path = load_landmarks(landmarks_url, cache_dir)

smiler = Smiler(landmarks_path, model_path)

fg = smiler.frame_generator(video_fn)
threshold = smiler.calc_threshold(fg, quantile)
fg = smiler.frame_generator(video_fn)
ffg = smiler.filter_frames(fg, threshold)

smile_score, image = smiler.find_smiliest_frame(ffg)

重新训练

Github仓库中的scripts目录中包含一些脚本,用于生成新图像以及辅助手动分类和模型重新训练。

项目详情


下载文件

下载适用于您平台上的文件。如果您不确定选择哪一个,请了解更多关于安装包的信息。

源代码分发

choirless_smiler-1.2.1.tar.gz (301.0 kB 查看哈希值)

上传时间 源代码

由以下支持