# calligraphy_gen **Repository Path**: wddark/calligraphy_gen ## Basic Information - **Project Name**: calligraphy_gen - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-03 - **Last Updated**: 2025-07-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 环境搭建 基于conda ```bash conda create --name calligraphy python=3.10 conda activate calligraphy # linux pip install -r requirements.txt # windows nvidia-smi # 查看cuda版本 # cuda12 pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 # cuda 11.8 pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 # CUDA 11.7 pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117 ``` ```python import torch print(f"PyTorch 版本: {torch.__version__}") print(f"CUDA 可用: {torch.cuda.is_available()}") print(f"CUDA 版本: {torch.version.cuda}") print(f"GPU 设备: {torch.cuda.get_device_name(0)}") ``` linux需要安装字体 ```bash # 更新包列表 sudo apt update # 安装文泉驿中文字体 sudo apt install fonts-wqy-microhei fonts-wqy-zenhei # 安装Google Noto中文字体 sudo apt install fonts-noto-cjk # 安装Microsoft Core Fonts(包含中文字体) sudo apt install ttf-mscorefonts-installer ``` # 运行 ```bash #准备数据 python generate_standard_fonts.py # 训练(几百张图片的500轮即可,几千张德 用1000轮) python calligraphy_gen.py train --content-dir standard_fonts --style-dir data --model-dir models --epochs 500 --batch-size 8 python calligraphy_gen.py train --content-dir standard_fonts --style-dir data --model-dir models --epochs 1000 --batch-size 8 # 推理 python calligraphy_gen.py infer --model-path models/calligraphy_style_model.pt --style-image data/永.png --text "蒸汽朋克" --output-dir results python calligraphy_gen.py infer \ --model-path models/best_calligraphy_model.pt \ --style-char 永 \ --text "蒸永" \ --output-dir results ```