Calligrapher2025 commited on
Commit
be5197c
Β·
verified Β·
1 Parent(s): c4a6f30

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +135 -0
README.md ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Calligrapher: Freestyle Text Image Customization
2
+
3
+ <div align="center">
4
+ <img src="https://huggingface.co/Calligrapher2025/Calligrapher/resolve/main/docs/static/images/teaser.jpg" width="850px" alt="Calligrapher Teaser">
5
+ </div>
6
+
7
+ <div align="center">
8
+ <h3>πŸ“„ <a href="https://calligrapher2025.github.io/Calligrapher/">Project Page</a> | πŸ“¦ <a href="https://github.com/Calligrapher2025/Calligrapher">Code</a> | πŸŽ₯ <a href="https://youtu.be/FLSPphkylQE">Video</a></h3>
9
+ </div>
10
+
11
+ ## 🎯 Overview
12
+
13
+ **Calligrapher** is a novel diffusion-based framework that innovatively integrates advanced text customization with artistic typography for digital calligraphy and design applications. Our framework supports text customization under various settings including self-reference, cross-reference, and non-text reference customization.
14
+
15
+ ## ✨ Key Features
16
+
17
+ - **🎨 Freestyle Text Customization**: Transform text with diverse stylized images and text prompts
18
+ - **πŸ”„ Various Reference Modes**: Support for self-reference, cross-reference, and non-text reference customization
19
+ - **πŸš€ High-Quality Results**: Photorealistic text image customization with consistent typography
20
+
21
+ ## πŸ“¦ Repository Contents
22
+
23
+ This Hugging Face repository contains:
24
+
25
+ - **`calligrapher.bin`**: Pre-trained Calligrapher model weights.
26
+ - **`Calligrapher_bench_testing`**: Comprehensive test dataset with examples for both self-reference and cross-reference customization scenarios with additional reference images for testing, omitting a small portion of samples due to IP concerns.
27
+
28
+
29
+
30
+ ## πŸ› οΈ Quick Start
31
+
32
+ ### Installation
33
+
34
+ We provide two ways to set up the environment (requiring Python 3.10 + PyTorch 2.5.0 + CUDA):
35
+
36
+ #### Using pip
37
+ ```bash
38
+ # Clone the repository
39
+ git clone https://github.com/Calligrapher2025/Calligrapher.git
40
+ cd Calligrapher
41
+
42
+ # Install dependencies
43
+ pip install -r requirements.txt
44
+ ```
45
+
46
+ #### Using Conda
47
+ ```bash
48
+ # Clone the repository
49
+ git clone https://github.com/Calligrapher2025/Calligrapher.git
50
+ cd Calligrapher
51
+
52
+ # Create and activate conda environment
53
+ conda env create -f env.yml
54
+ conda activate calligrapher
55
+ ```
56
+
57
+ ### Download Models & Testing Data
58
+
59
+ ```python
60
+ from huggingface_hub import snapshot_download
61
+
62
+ # Download Calligrapher model and test data
63
+ snapshot_download("Calligrapher2025/Calligrapher")
64
+
65
+ # Download required base models (granted access needed)
66
+ snapshot_download("black-forest-labs/FLUX.1-Fill-dev", token="your_token")
67
+ snapshot_download("google/siglip-so400m-patch14-384")
68
+ ```
69
+
70
+ ### Configuration
71
+
72
+ Before running the models, you need to configure the paths in `path_dict.json`:
73
+
74
+ ```json
75
+ {
76
+ "data_dir": "path/to/Calligrapher_bench_testing",
77
+ "cli_save_dir": "path/to/cli_results",
78
+ "gradio_save_dir": "path/to/gradio_results",
79
+ "gradio_temp_dir": "path/to/gradio_tmp",
80
+ "base_model_path": "path/to/FLUX.1-Fill-dev",
81
+ "image_encoder_path": "path/to/siglip-so400m-patch14-384",
82
+ "calligrapher_path": "path/to/calligrapher.bin"
83
+ }
84
+ ```
85
+
86
+ Configuration parameters:
87
+ - `data_dir`: Path to store the test dataset
88
+ - `cli_save_dir`: Path to save results from command-line interface experiments
89
+ - `gradio_save_dir`: Path to save results from Gradio interface experiments
90
+ - `gradio_temp_dir`: Path to save temporary files.
91
+ - `base_model_path`: Path to the base model FLUX.1-Fill-dev
92
+ - `image_encoder_path`: Path to the SigLIP image encoder model
93
+ - `calligrapher_path`: Path to the Calligrapher model weights
94
+
95
+ ### Run Gradio Demo
96
+
97
+ ```bash
98
+ # Basic Gradio demo
99
+ python gradio_demo.py
100
+
101
+ # Demo with custom mask upload (recommended for first-time users)
102
+ # This version includes pre-configured examples and is recommended for users to first understand how to use the model
103
+ python gradio_demo_upload_mask.py
104
+ ```
105
+
106
+ ## 🎨 Command Line Usage Examples
107
+
108
+ ### Self Customization
109
+ ```bash
110
+ python infer_calligrapher_self_custom.py
111
+ ```
112
+
113
+ ### Cross Customization
114
+ ```bash
115
+ python infer_calligrapher_cross_custom.py
116
+ ```
117
+
118
+ **Note:** Image result files starting with "result" are the customization outputs, while files starting with "vis_result" are concatenated results showing the source image, reference image, and model output together.
119
+
120
+ ## πŸ“Š Framework
121
+
122
+ <div align="center">
123
+ <img src="https://huggingface.co/Calligrapher2025/Calligrapher/resolve/main/docs/static/images/framework.jpg" width="900px" alt="Calligrapher Framework">
124
+ </div>
125
+
126
+ Our framework integrates localized style injection and diffusion-based learning, featuring:
127
+ - **Self-distillation mechanism** for automatic typography benchmark construction.
128
+ - **Localized style injection** via trainable style encoder.
129
+ - **In-context generation** for enhanced style alignment.
130
+
131
+ ## 🎭 Results Gallery
132
+
133
+ <div align="center">
134
+ <img src="https://huggingface.co/Calligrapher2025/Calligrapher/resolve/main/docs/static/images/application.jpg" width="900px" alt="Calligrapher Applications">
135
+ </div>