Image Classification
ONNX
onnxruntime
document-orientation
deskew
ocr
image-preprocessing
cpu
folio-orient / training /network.py
foliokestrel's picture
Add an optional eight-way mirrored-print model, offline CLI and evaluated operating points
5c3729a verified
Raw History Blame Contribute Delete
784 Bytes
"""Classify a print patch by its correcting quarter-turn and optional reflection."""
from torch import nn
class PatchOrient(nn.Sequential):
def __init__(self, classes=4):
layers = []
previous = 1
for channels in (16, 24, 48, 64):
for stride in (2, 1):
layers.extend(
[
nn.Conv2d(
previous, channels, 3, stride=stride, padding=1, bias=False
),
nn.BatchNorm2d(channels),
nn.ReLU(),
]
)
previous = channels
super().__init__(
*layers, nn.AdaptiveAvgPool2d(1), nn.Flatten(), nn.Linear(previous, classes)
)