---
license: mit
language:
- zh
- en
tags:
- thangka
- image-restoration
- stable-diffusion
- lora
- cultural-heritage
- paddlepaddle
- buddhist-art
datasets:
- custom-thangka-1376
metrics:
- psnr
- ssim
pipeline_tag: image-to-image
widget:
- text: "traditional thangka art, Shakyamuni Buddha, detailed painting, vibrant colors, gold outlines"
example_title: "Buddha Restoration"
- text: "traditional thangka art, Green Tara, 18th century Tibetan style, mineral pigments, masterpiece"
example_title: "Tara Restoration"
---
[](https://github.com/WangchukMind/thangka-restoration-ai)
[](LICENSE)
[](https://paddlepaddle.org.cn)
[](https://huggingface.co/Wangchuk1376)
**🎨 唐卡修复AI模型 / Thangka Restoration AI Models**
[English](#english-version) | [中文](#chinese-version)
The Thangka Restoration AI Models are a collection of deep learning models specifically designed for **Tibetan Buddhist Thangka art restoration**. Built upon the latest **Stable Diffusion 2.1** architecture and **LoRA (Low-Rank Adaptation)** fine-tuning technology, these models are meticulously trained on **1376** professionally annotated high-quality Thangka images.
### Why AI for Thangka Restoration?
Thangka, as an important art form of Tibetan Buddhism, carries profound religious and cultural significance, known as the "**Encyclopedia of Tibet**". However:
- 📜 **Fragile Materials**: Cotton, silk, and mineral pigments are easily damaged
- ⏰ **Historical Age**: Many Thangkas are centuries old
- 💰 **Expensive Restoration**: Traditional manual restoration is costly and time-consuming
- 👨🎨 **Expert Scarcity**: Limited number of professional restorers
- ⚠️ **High Risk**: Chemical restoration may cause secondary damage
This project leverages AI technology to provide:
- ✅ **Efficient Restoration**: Complete initial restoration in minutes
- ✅ **Cultural Accuracy**: >95% cultural feature preservation
- ✅ **Cost Reduction**: Significantly lower restoration barriers
- ✅ **Non-destructive**: Virtual restoration without damaging originals
### 项目链接
- **完整系统**: [GitHub Repository](https://github.com/WangchukMind/thangka-restoration-ai)
- **模型仓库**: [Hugging Face Models](https://huggingface.co/Wangchuk1376/ThangkaModels)
- **在线演示**: [Demo Site](https://api-ydh5rc33c7a9bbs2.aistudio-app.com/)
- **技术文档**: [Documentation](https://github.com/WangchukMind/thangka-restoration-ai/wiki)
## 🌟 项目简介
这是一套专门用于藏传佛教唐卡艺术修复的AI模型集合,基于**Stable Diffusion 2.1**和**LoRA微调技术**,在专业标注的唐卡图像上训练而成。
### 核心特点
- ✅ **高效修复**: 基于LoRA技术,快速适应不同风格
- ✅ **多种模型**: 提供多个LoRA模型,适应不同修复需求
- ✅ **PaddlePaddle**: 完全适配PaddlePaddle深度学习框架
### 开发信息
- **开发者**: Wangchuk Mind
- **机构**: 四川大学计算机学院
- **框架**: PaddlePaddle 2.6.2
- **基础模型**: Stable Diffusion 2.1
- **许可证**: MIT License
---
## 📦 模型列表
### 1. 基础模型
#### Stable Diffusion 2.1 Base (PaddlePaddle版)
- **输入分辨率**: 512×512 (标准), 768×768, 1024×1024
### 2. LoRA微调模型
#### thangka_21_Status_140 ⭐ (推荐)
#### thangka_21_ACD_250
### 3. PaddlePaddle专用模型
位于 `models/finetuned_paddle/` 和 `models/sd2.1_base_paddle/`,这些是转换为PaddlePaddle格式的模型文件(`.pdparams`),可直接在PaddlePaddle框架中使用。
## 💻 使用方法
### 环境要求
```bash
# Python版本
Python >= 3.9
# 核心依赖
paddlepaddle-gpu >= 2.6.0 # GPU版本 (推荐)
# 或
paddlepaddle >= 2.6.0 # CPU版本
# 其他依赖
pip install Pillow opencv-python numpy
```
### 快速开始
#### 1. 基础修复示例
```python
import paddle
from PIL import Image
import numpy as np
# 这里是简化的示例,完整代码请参考GitHub仓库
# https://github.com/WangchukMind/thangka-restoration-ai
# 加载模型 (伪代码 - 实际使用请参考完整系统)
from diffusion_paddle import load_model, load_lora, inpaint
# 加载基础模型
pipe = load_model(
model_path="models/sd2.1_base_paddle",
device="gpu" # 或 "cpu"
)
# 加载LoRA模型
load_lora(pipe, "models/finetuned/thangka_21_Status_140.safetensors")
# 加载待修复图像
image = Image.open("damaged_thangka.png").resize((512, 512))
mask = Image.open("damage_mask.png").resize((512, 512))
# 执行修复
result = inpaint(
pipe=pipe,
image=image,
mask=mask,
prompt="traditional thangka art, Buddha, detailed, vibrant colors, gold outlines",
negative_prompt="low quality, blurry, distorted, modern style",
num_inference_steps=30,
guidance_scale=7.5,
strength=0.8
)
# 保存结果
result.save("restored_thangka.png")
```
#### 2. 使用ControlNet边缘控制
```python
# 加载ControlNet
from diffusion_paddle import load_controlnet
controlnet = load_controlnet("models/control_v11p_sd21_canny_paddle")
# 提取边缘
from skimage.feature import canny
edges = canny(np.array(image.convert('L')), sigma=1)
edge_image = Image.fromarray((edges * 255).astype(np.uint8))
# 使用ControlNet修复
result = inpaint_with_control(
pipe=pipe,
image=image,
mask=mask,
control_image=edge_image,
controlnet=controlnet,
prompt="traditional thangka art, detailed restoration",
num_inference_steps=30
)
```
### 完整系统安装
完整的Web应用系统请访问GitHub:
```bash
# 克隆完整系统
git clone https://github.com/WangchukMind/thangka-restoration-ai.git
cd thangka-restoration-ai
# 安装依赖
cd Django
pip install -r requirements_paddle.txt
# 下载模型文件
# 模型文件较大,请从以下地址下载:
# Hugging Face: https://huggingface.co/Wangchuk1376/ThangkaModels
# 或参考 MODEL_DOWNLOAD.md
# 启动系统
python start_server.py runserver
# 或使用MVP简化版本
cd ..
python start_mvp_product.py
```
访问 `http://localhost:3000` 使用Web界面。
### 问题反馈
- **Bug报告**: [GitHub Issues](https://github.com/WangchukMind/thangka-restoration-ai/issues)
- **功能建议**: [GitHub Discussions](https://github.com/WangchukMind/thangka-restoration-ai/discussions)
- **技术交流**: [Discussions](https://huggingface.co/Wangchuk1376/ThangkaModels/discussions)
---
## 🌟 Star History
如果这个项目对您有帮助,请给我们一个⭐️!
[](https://star-history.com/#WangchukMind/thangka-restoration-ai&Date)
### Contact
- **Developer**: Wangchuk Mind
- **GitHub**: [@WangchukMind](https://github.com/WangchukMind)
- **Hugging Face**: [@Wangchuk1376](https://huggingface.co/Wangchuk1376)
---
**🎨 Preserving millennium-old Thangka culture with AI technology!**