跳转到主要内容

使用Salesforce BLIP生成图像的标题

项目描述

blip-caption

PyPI Changelog Tests License

一个用于使用 Salesforce BLIP 生成图像标题的CLI工具。

安装

使用 pippipx 安装此工具

pipx install blip-caption

首次使用此工具时,它将从Hugging Face模型中心下载模型。

小型模型为945MB。大型模型为1.8GB。首次使用这些模型时,它们将下载并存储在 ~/.cache/huggingface/hub/

用法

要使用小型模型生成图像的标题,请运行

blip-caption IMG_5825.jpeg

示例输出

a lizard is sitting on a branch in the woods

要使用大型模型,请添加 --large

blip-caption IMG_5825.jpeg --large

示例输出

there is a chamelon sitting on a branch in the woods

这是 我使用的图像

It is ineded a chameleon

如果传递多个文件,则在每个文件的标题之前将输出其路径

blip-caption /tmp/photos/*.jpeg
/tmp/photos/IMG_2146.jpeg
a man holding a bowl of salad and laughing
/tmp/photos/IMG_0151.jpeg
a cat laying on a red blanket

JSON输出

使用 --json 标志,输出将类似于以下内容

blip-caption /tmp/photos/*.* --json
[{"path": "/tmp/photos/IMG_2146.jpeg", "caption": "a man holding a bowl of salad and laughing"},,
 {"path": "/tmp/photos/IMG_0151.jpeg", "caption": "a cat laying on a red blanket"},
 {"path": "/tmp/photos/IMG_3099.MOV", "error": "cannot identify image file '/tmp/photos/IMG_3099.MOV'"}]

任何错误都作为 {"path": "...", "error": "error message"} 对象返回。

开发

要本地设置此插件,首先检出代码。然后创建一个新的虚拟环境

cd blip-caption
python3 -m venv venv
source venv/bin/activate

现在安装依赖项和测试依赖项

pip install -e '.[test]'

要运行测试

pytest

项目详情


下载文件

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

源分发

blip-caption-0.1.tar.gz (3.8 kB 查看哈希)

上传于 源代码

构建版本

blip_caption-0.1-py3-none-any.whl (3.3 kB 查看哈希)

上传于 Python 3

由以下支持