Generate realistic handwritten text using deep learning
Features • Installation • Usage • Examples
A neural network-based handwriting synthesis system that generates realistic, customizable handwritten text. Choose from 10 different handwriting styles, adjust randomness, colors, and stroke properties to create unique handwritten content.
- 🎨 10 Unique Styles - Multiple handwriting personalities to choose from
- 🎬 Animated Drawing - Watch text being written in real-time
- 🎲 Customizable Randomness - Control variation for natural-looking results
- 🌈 Color & Stroke Control - Personalize appearance with colors and widths
- 📝 Multi-line Support - Generate entire paragraphs at once
- 💾 SVG Output - Scalable vector graphics for perfect quality
- 🖥️ Interactive Web UI - Beautiful Streamlit interface
- Python 3.7.9 (Required for TensorFlow compatibility)
- pip package manager
-
Clone the repository
git clone https://github.com/Jash4305/Handwriting-Synthesis.git cd Handwriting-Synthesis -
Create virtual environment
python -m venv env # Windows env\Scripts\activate # macOS/Linux source env/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Install Streamlit (for web UI)
pip install streamlit
Launch the interactive web app:
streamlit run app.pyThis opens a browser with:
- Text input area
- Style selector (0-9)
- Randomness controls
- Animation toggle
- Color picker
- Download button
Quick generation from terminal:
from demo import Hand
# Initialize
hand = Hand()
# Generate handwriting
hand.write(
filename='output.svg',
lines=['Hello World!', 'This is amazing!'],
biases=[0.75, 0.75],
styles=[5, 5],
stroke_colors=['black', 'blue'],
stroke_widths=[2, 2]
)| Parameter | Type | Description | Example |
|---|---|---|---|
lines |
list[str] | Text to generate | ['Hello', 'World'] |
biases |
list[float] | Randomness (0.5-1.5) | [0.75, 0.75] |
styles |
list[int] | Style IDs (0-9) | [5, 7] |
stroke_colors |
list[str] | Colors per line | ['red', 'blue'] |
stroke_widths |
list[int] | Pen thickness (1-5) | [2, 2] |
- Python 3.7.9 - Core programming language
- TensorFlow 1.x - Neural network framework
- NumPy - Numerical computations
- Streamlit - Web interface
- Matplotlib - Visualization
- SciPy - Signal processing
Handwriting-Synthesis/
├── demo.py # Core synthesis code
├── drawing.py # Utility functions
├── handwriting_app.py # Streamlit web interface
├── styles/ # Pre-trained handwriting styles
├── imgs/ # Sample output images
├── outputs/ # Generated files
├── requirements.txt # Python dependencies
└── README.md # Documentation
- Best Style: Try style 5 or 7 for clean, readable handwriting
- Natural Look: Use bias around 0.75 for realistic variation
- Longer Text: Break into multiple short lines for better results
- Animation Speed: Set to 1.5-2.0 for smooth, watchable animation
- Colors: Darker colors (#000000 - #333333) look most realistic
If you see deprecation warnings, they're harmless and won't affect functionality. To suppress:
import warnings
warnings.filterwarnings('ignore')Must use Python 3.7.9 for TensorFlow 1.x compatibility. Check your version:
python --versionInstall all requirements:
pip install -r requirements.txt --break-system-packagesThis project is licensed under the MIT License - see the LICENSE file for details.
Based on research in handwriting synthesis using recurrent neural networks and mixture density networks.
