Python 图像挖掘
项目描述
PIMMI : Python 图像挖掘
PIMMI 是一个在图像语料库中执行视觉挖掘的软件。其主要目标是找到大量图像中的所有复制品,无论是完全还是部分复制品,并将它们分组。我们的初始目标是研究社交网络上图像的再利用(例如,我们的第一次使用是 Twitter 上表情包的传播)。然而,我们认为它的用途可以更广泛,并且可以很容易地适应其他研究。PIMMI 的主要功能因此是
- 能够处理大型图像语料库,高达数百万个文件
- 对图像的某些修改具有鲁棒性,这些修改是社交网络上图像再利用的典型特征(裁剪、缩放、组合、添加文本等)
- 足够灵活,可以适应不同的用例(主要是图像语料库的性质和数量)
PIMMI 目前仅专注于视觉挖掘,因此不管理与图像相关的元数据。这些元数据是每个研究特有的,因此超出了我们的范围。因此,使用 PIMMI 的研究通常将分解为几个步骤
- 组成图像语料库(jpg 和/或 png 文件)及其元数据
- 根据语料库的标准选择 PIMMI 参数
- 使用 PIMMI 索引图像并获得复用图像的聚类
- 通过将它们与图像的描述性元数据相结合来利用聚类
PIMMI 依赖于现有技术并将它们集成到一个简单的数据管道中
- 使用成熟的本地图像描述符(尺度不变特征变换:SIFT)将图像表示为关键点的集合。还使用几何一致性验证。(OpenCV 的实现适用于两者)。
- 为了适应大量图像,它依赖于一个知名的向量索引库,该库提供了一些最有效的算法实现(FAISS),以查询关键点数据库。
- 使用标准社区检测算法在相似性图上对相似图像进行分组。
PIMMI 是一个用 Python 开发的库,可以通过命令行界面使用。它是多线程的。还提供了一个基本的网页界面来可视化结果,但更多的是作为一个示例,而不是用于大量使用(Pimmi-ui)。
本软件的开发仍在进行中:我们热烈欢迎测试人员、反馈、新功能建议甚至拉取请求!
初始作者
使用 pyenv 和 pip 安装
pyenv virtualenv 3.7.0 pimmi-env
pyenv activate pimmi-env
pip install -U pip
pip install pimmi
从源代码安装
python3 -m venv /tmp/pimmi-env
source /tmp/pimmi-env/bin/activate
pip install -U pip
git clone git@github.com:nrv/pimmi.git
cd pimmi
pip install -r requirements.txt
pip install -e .
演示
# --- Play with the demo dataset 1
# Create a default index structure and fill it with the demo dataset. An 'index' directory will be created,
# it will contain the 2 files of the pimmi index : dataset1.IVF1024,Flat.faiss and
# dataset1.IVF1024,Flat.meta
pimmi fill demo_dataset/dataset1 dataset1
# Query the same dataset on this index, the results will be stored in
# index/dataset1.IVF1024,Flat.mining_000000.csv
pimmi query demo_dataset/dataset1 dataset1
# Post process the mining results in order to visualize them
pimmi clusters dataset1
# You can also play with the configuration parameters. First, generate a default configuration file
pimmi create-config my_pimmi_conf.yml
# Then simply use this configuration file to relaunch the mining steps (erasing without prompt the
# previous data)
pimmi fill --erase --force --config-path my_pimmi_conf.yml demo_dataset/dataset1 dataset1
pimmi query --config-path my_pimmi_conf.yml demo_dataset/dataset1 dataset1
pimmi clusters --config-path my_pimmi_conf.yml dataset1
在 Copydays 数据集上测试
您可以在这里找到数据集说明。不幸的是,数据文件不再可用,您可以从网络存档获取。
创建项目结构并在同一图像目录下解压缩所有文件。
copydays
└───index
└───images
└───crop
│ └───crops
│ └───10
│ └───15
│ └───20
│ └───30
│ └───40
│ └───50
│ └───60
│ └───70
│ └───80
└───original
└───jpeg
│ └───jpegqual
│ └───3
│ └───5
│ └───8
│ └───10
│ └───15
│ └───20
│ └───30
│ └───50
│ └───75
└───strong
然后您可以玩不同的参数并评估结果。如果您想遍历多个参数以优化设置,可以查看 eval_copydays.sh。
cd scripts
mkdir index
pimmi --sift-nfeatures 1000 --index-type IVF1024,Flat fill /path/to/copydays/images/ copydays
pimmi --query-sift-knn 1000 --query-dist-ratio-threshold 0.8 --index-type IVF1024,Flat query /path/to/copydays/images/ copydays
pimmi --index-type IVF1024,Flat --algo components clusters copydays
python copydays_groundtruth.py /path/to/copydays/images/ index/copydays.IVF1024,Flat.mining.clusters.csv
pimmi eval index/copydays.IVF1024,Flat.mining.groundtruth.csv --query-column image_status
cluster precision: 0.9924645454677958
cluster recall: 0.7406974660159374
cluster f1: 0.7856752626502786
query average precision: 0.8459113427266295
祝您编程愉快!
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
pimmi-0.3.0.tar.gz (36.4 kB 查看哈希)
构建分发
pimmi-0.3.0-py3-none-any.whl (37.7 kB 查看哈希)
关闭
pimmi-0.3.0.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c3ef46f2edaa89f21dd34d133b6a8819f4c7f469ece410a37d2c5a1406ef1b7b |
|
MD5 | 21a07790e6a8f25d9a09d9567c5f5237 |
|
BLAKE2b-256 | e19e6e9b82085fbe02c803f5e661e7115d84abee8cdbaa9ae84dc032742f28b3 |
关闭
pimmi-0.3.0-py3-none-any.whl 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 98f89d1b09c823b7c60c01fddeb3ab3d5be0ab38aa0af4e3d5162df486878ed0 |
|
MD5 | f8226f2aa9a2c5b3a443f457fbd88721 |
|
BLAKE2b-256 | 8993582d8b5e9d6c8066407b7dd2c0214dc905d11631eaa3062262c055278b5d |