{"id":16392689,"url":"https://github.com/facundoq/rotational_invariance_data_augmentation","last_synced_at":"2025-08-24T09:35:17.656Z","repository":{"id":75050613,"uuid":"172560797","full_name":"facundoq/rotational_invariance_data_augmentation","owner":"facundoq","description":"Code for \"Revisiting Data Augmentation for Rotational Invariance in Convolutional Neural Networks\"","archived":false,"fork":false,"pushed_at":"2022-11-02T03:34:18.000Z","size":73,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T19:35:17.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/facundoq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-25T18:25:18.000Z","updated_at":"2023-02-23T03:10:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"a0845159-e7c6-4585-a818-7cd26bbca7f1","html_url":"https://github.com/facundoq/rotational_invariance_data_augmentation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facundoq%2Frotational_invariance_data_augmentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facundoq%2Frotational_invariance_data_augmentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facundoq%2Frotational_invariance_data_augmentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facundoq%2Frotational_invariance_data_augmentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/facundoq","download_url":"https://codeload.github.com/facundoq/rotational_invariance_data_augmentation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238337680,"owners_count":19455357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T04:50:59.376Z","updated_at":"2025-02-11T17:33:18.758Z","avatar_url":"https://github.com/facundoq.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Revisiting Data Augmentation for Rotational Invariance in Convolutional Neural Networks\n\nThis repository contains the code necessary to obtain the experimental results published in the article *Revisiting Data Augmentation for Rotational Invariance in Convolutional Neural Networks* (link and bib entry coming soon).\n\n## Abstract\n`Convolutional Neural Networks (CNN) offer state of the art performance in various computer vision tasks. Many of those tasks require different subtypes of affine invariances (scale, rotational, translational) to image transformations. Convolutional layers are translation equivariant by design, but in their basic form lack invariances. In this work we investigate how best to include rotational invariance in a CNN for image classification. Our experiments show that networks trained with data augmentation alone can classify rotated images nearly as well as in the normal unrotated case; this increase in representational power comes only at the cost of training time. We also compare data augmentation versus two modified CNN models for achieving rotational invariance or equivariance, Spatial Transformer Networks and Group Equivariant CNNs, finding no significant accuracy increase with these specialized methods. In the case of data augmented networks, we also analyze which layers help the network to encode the rotational invariance, which is important for understanding its limitations and how to best retrain a network with data augmentation to achieve invariance to rotation.`\n\n## What can you do with this code\n\nYou can train a model on the [MNIST](http://yann.lecun.com/exdb/mnist/) or [CIFAR10](https://www.cs.toronto.edu/~kriz/cifar.html) datasets. Two models will be generated for each training; a *rotated* model, for which the dataset's samples were randomly rotated before, and an *unrotated* model, for which they weren't modified at all.\n\nThe available models are the [AllConvolutional network](https://arxiv.org/abs/1412.6806) and a [simple Convolutional Network](https://github.com/facundoq/rotational_invariance_data_augmentation/blob/master/pytorch/model/simple_conv.py) with or without a [Spatial Transformer Layer](https://arxiv.org/abs/1506.02025) or with modified [Group Equivariant Convolutional Layers](https://arxiv.org/abs/1602.07576). \n\n## How to run\n\nThese instructions have been tested on a modern ubuntu-based distro with python version\u003e=3.5.  \n\n* Clone the repository and cd to it:\n    * `git clone https://github.com/facundoq/rotational_invariance_data_augmentation.git`\n    * `cd rotational_invariance_data_augmentation` \n* Create a virtual environment and activate it (requires python3 with the venv module and pip):\n    * `python3 -m venv .env`\n    * `source .env/bin/activate`\n* Install libraries\n    * `pip install -r requirements.txt`\n* Install [GrouPy with PyTorch support](https://github.com/adambielski/GrouPy)\n   * `mkdir ~/dev` (or whenever you want to download GrouPy's repo)\n   * `cd ~/dev`\n   * `git clone https://github.com/adambielski/GrouPy.git`\n   * `cd GrouPy`\n   * `python setup.py install` (make sure the venv is active for this step)\n   * go back this repo's folder\n   \n* Run the experiments with `python experiment_name\u003e \u003cmodel\u003e \u003cdataset\u003e`\n    * `experiment_rotation.py` trains two models with the dataset: one with the vanilla version, the other with a data-augmented version via rotations.\n    * `experiment_accuracy_vs_rotation.py` evaluates how the model's accuracy varies wrt the rotation of the samples\n    * `experiment_retraining.py` (NOT YET AVAILABLE) Evaluates the accuracy of a model trained on a unrotated dataset after retraining some parts of it. \n* The folder `plots` contains the results for any given model/dataset combination\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacundoq%2Frotational_invariance_data_augmentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffacundoq%2Frotational_invariance_data_augmentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacundoq%2Frotational_invariance_data_augmentation/lists"}