Skip to content

Jash4305/Handwriting-Synthesis

Repository files navigation

✍️ Handwriting Synthesis

Python Version License TensorFlow

Generate realistic handwritten text using deep learning

FeaturesInstallationUsageExamples


🎯 What is This?

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.

Handwriting Sample 1

✨ Features

  • 🎨 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

🚀 Installation

Prerequisites

  • Python 3.7.9 (Required for TensorFlow compatibility)
  • pip package manager

Setup

  1. Clone the repository

    git clone https://github.com/Jash4305/Handwriting-Synthesis.git
    cd Handwriting-Synthesis
  2. Create virtual environment

    python -m venv env
    
    # Windows
    env\Scripts\activate
    
    # macOS/Linux
    source env/bin/activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Install Streamlit (for web UI)

    pip install streamlit

📖 Usage

Option 1: Web Interface (Recommended)

Launch the interactive web app:

streamlit run app.py

This opens a browser with:

  • Text input area
  • Style selector (0-9)
  • Randomness controls
  • Animation toggle
  • Color picker
  • Download button

Option 2: Command Line

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]
)

Parameters Explained

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]

🖼️ Sample Outputs


🛠️ Tech Stack

  • Python 3.7.9 - Core programming language
  • TensorFlow 1.x - Neural network framework
  • NumPy - Numerical computations
  • Streamlit - Web interface
  • Matplotlib - Visualization
  • SciPy - Signal processing

📁 Project Structure

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

💡 Tips & Tricks

  • 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

🐛 Troubleshooting

TensorFlow/NumPy Warnings

If you see deprecation warnings, they're harmless and won't affect functionality. To suppress:

import warnings
warnings.filterwarnings('ignore')

Python Version Issues

Must use Python 3.7.9 for TensorFlow 1.x compatibility. Check your version:

python --version

Missing Dependencies

Install all requirements:

pip install -r requirements.txt --break-system-packages

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.


🙏 Acknowledgments

Based on research in handwriting synthesis using recurrent neural networks and mixture density networks.


⭐ Star this repo if you found it helpful!

About

Generates Handwritten text using RNN

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages