Calligrapher-2025 模型部署教程Calligrapher可以提供个性化的文本图像定制,它允许用户使用各种风格化的图像和文本提示执行自定义。

##目前模型支持英文的修改,支持青春版A100使用。
详细信息可以参考:Calligrapher2025/Calligrapher:书法家:Freestyle 文字图片定制 Calligrapher2025/Calligrapher · Hugging Face
部署环境
| ubuntu | 22.04 |
|---|---|
| cuda | 12.1.1 |
| python | 3.10 |
| NVIDIA Corporation | A100 SXM4 |
模型运行所需显存较高,且只能选择单张卡,建议选择高显存卡
文档中建议Python 3.10 + PyTorch 2.5.0 + CUDA,注意版本需要相匹配
查看系统版本信息
#查看系统的版本信息,包括ID(如ubuntu、centos等)、版本号、名称、版本号ID等
cat /etc/os-release

配置国内源

apt 配置阿里源

将以下内容粘贴进文件中
deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb http://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main
deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
查看系统是否有 miniconda 的环境
conda -V

显示如上输出,即安装了相应环境,若没有 miniconda 的环境,通过以下方法进行安装
#下载 Miniconda 安装脚本
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
#运行 Miniconda 安装脚本
bash Miniconda3-latest-Linux-x86_64.sh
#初次安装需要激活 base 环境
source ~/.bashrc
按下回车键(enter)

输入 yes

输入 yes

安装成功如下图所示

创建名为Calligrapher的虚拟环境
conda create -n Calligrapher python=3.10 -y

激活虚拟环境
conda activate Calligrapher
输入命令克隆仓库并进入到项目之中
git clone https://github.com/Calligrapher2025/Calligrapher.git


出现successfully则安装成功


运行模型下载工具,自定义模型下载位置
from huggingface_hub import snapshot_download
# Download the base model FLUX.1-Fill-dev (granted access needed)
snapshot_download("black-forest-labs/FLUX.1-Fill-dev", token="your_token")
# Download SigLIP image encoder (this model can also be automatically downloaded when running the code)
snapshot_download("google/siglip-so400m-patch14-384")
# Download Calligrapher model and test data
snapshot_download("Calligrapher2025/Calligrapher")
下载内容包括Calligrapher模型权重、基础模型FLUX.1-Fill-dev、SigLIP 图像编码器模型以及测试数据集

path_dict.json将路径修改为实际的存储地址
{
"data_dir": "path/to/Calligrapher_bench_testing",
"cli_save_dir": "path/to/cli_results",
"gradio_save_dir": "path/to/gradio_results",
"gradio_temp_dir": "path/to/gradio_tmp",
"base_model_path": "path/to/FLUX.1-Fill-dev",
"image_encoder_path": "path/to/siglip-so400m-patch14-384",
"calligrapher_path": "path/to/calligrapher.bin"
}
下载其他缺失依赖包

访问界面
# Basic Gradio demo
python gradio_demo.py

下面是Gradio演示界面

将自己选中的图片放进预选框,然后将图片放进编辑框

将图片拖入编辑框,并且选中画笔将需要修改的地方进行涂抹

输入想要修改的文字

根据需求调整

点击运行,等待过后得到结果

其他演示图



