Convert Typed Text-Image Into Handwritten Style Using Adverserial Methods
- Install Dependencies
$ pip install -r requirements.txt
- Download Pretrained Weights Here
- Project Structure
.
├── src
│ ├── nn
│ │ ├── Decoder.py
│ │ ├── Discriminator.py
│ │ ├── Encoder.py
│ │ ├── Layers.py
│ │ └── Unet.py
│ └── utils
│ ├── DataProvider.py
│ ├── Losses.py
│ ├── misc.py
│ └── transforms.py
├── config.py
├── prediction.py
└── train.py
The intensity loss is used to capture the pixel-wise differences between the predicted frame
Mathematical Formulation Given the predicted frame
where
By minimizing the intensity loss, the model learns to generate more accurate and realistic predictions of future frames, which is crucial for effective anomaly detection.
The gradient loss encourages the predicted frame to have similar gradient structures to the ground truth frame. This is done by computing the difference between the gradients of the predicted and ground truth frames.
Mathematical Formulation Given the predicted frame
where
The gradient of an image can be computed in both the x (horizontal) and y (vertical) directions. Let
In practice, the gradient loss is combined with other loss components, such as intensity loss and adversarial loss, to form a comprehensive loss function. This combined loss ensures that the predicted frames are not only accurate in terms of pixel values but also maintain structural and contextual consistency. The total loss function might be expressed as:
where
Project is distributed under MIT License