一个用于从视频中提取最迷人的图像的库和命令
项目描述
Smiler
这是一个库和CLI工具,用于从人物的视频中提取“最迷人”的帧。
它是作为Choirless项目的一部分开发的,作为IBM Call for code项目的一部分。
安装
% pip install choirless_smiler
用法
简单用法
% smiler video.mp4 snapshot.jpg
它将进行预扫描以确定与前一个帧相比变化最大的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 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c0067006fa26e993c961fa314d34192b4cda9643665c57a94a3d2f9fb53123ce |
|
MD5 | 5bd1057050e77f70f756ec5897f618b2 |
|
BLAKE2b-256 | 57fc5a7588392402bf33b357492df497219ad4f67b60e5d31d38f47023250100 |