$ show lumina37/rotate-captcha-crack
This repository provides a library and tools for training and deploying CNN models (RotNet, RotNetR) to predict the rotation angle of images, primarily designed for cracking rotate captchas. The system includes a training pipeline with customizable dataset preprocessing (random rotations, cropping, normalization), model definitions using ResNet50 and RegNet_Y backbones, a loss function optimized for angular classification (Circular Smooth Label), and an HTTP server for inference. The codebase is well-structured as a Python package with clean separation of concerns, showcasing advanced patterns like generic pipe operators for data transformation composition and context-managed training loops. It is actively maintained and demonstrates solid software engineering practices.
The LLM identified 2 files worth highlighting for reuse:
Provides generic pipe operators (FnSupportsPipe, IterSupportsPipe, SeqSupportsPipe) that enable composing data transformations using the '|' operator. This module is completely self-contained, importing only from Python standard library (typing, collections.abc), and demonstrates advanced use of protocols, runtime_checkable, and generics. It can be extracted into a separate library for any project needing lazy, composable pipelines, making it a highly reusable component.
Defines LRManager and LRManagerWithValLoss, which encapsulate the optimizer and learning rate scheduler behind a context manager. This pattern ensures correct ordering of zero_grad(), forward/backward, optimizer.step(), and scheduler.step(). It is self-contained (depends only on torch.optim) and provides a clean, reusable way to manage training steps, simplifying training loops in any PyTorch project.