From e7b075e35007d15e3e6469cc8078a5d0737b8cab Mon Sep 17 00:00:00 2001 From: Aditya Oke <47158509+oke-aditya@users.noreply.github.com> Date: Wed, 2 Dec 2020 18:09:13 +0530 Subject: [PATCH] Drops timm, fixes docs (#63) * drops timm, fixes docs * drops timm * tries fixing docs * patch up docs * final try for docs * fixes * one more chance --- .github/workflows/sphinx-docs-build.yml | 21 ++++-------- .github/workflows/sphinx-docs-deploy.yml | 34 ++++++++++++++----- .gitignore | 1 + docs/index.rst | 4 +-- docs/{ => source}/conf.py | 0 docs/source/setup.rst | 7 ---- .../models/classification/cnn/__init__.py | 1 - .../classification/cnn/model_factory.py | 20 +---------- requirements.txt | 1 - tests/test_cnn.py | 5 --- 10 files changed, 35 insertions(+), 59 deletions(-) rename docs/{ => source}/conf.py (100%) delete mode 100644 docs/source/setup.rst diff --git a/.github/workflows/sphinx-docs-build.yml b/.github/workflows/sphinx-docs-build.yml index 8c366af..e6bbaad 100644 --- a/.github/workflows/sphinx-docs-build.yml +++ b/.github/workflows/sphinx-docs-build.yml @@ -13,19 +13,10 @@ jobs: with: # git is required to clone the docs theme # before custom requirement are resolved https://github.com/ammaraskar/sphinx-action/issues/16 - pre-build-command: "sudo apt-get update -y && sudo apt-get install -y git && pip install . && pip install -r docs/requirements.txt" + pre-build-command: "sudo apt-get update -y && sudo apt-get install -y git && pip install -r docs/requirements.txt" + build-command: "sphinx-build -b html source build" docs-folder: "docs/" - - name: Test Documentation - env: - SPHINX_MOCK_REQUIREMENTS: 0 - run: | - # First run the same pipeline as Read-The-Docs - sudo apt-get install python3-sphinx - sudo apt-get install -y texlive-latex-extra dvipng texlive-pictures - sudo apt-get install -y cmake - pip install . - pip install -r docs/requirements.txt - cd docs - make clean - make html - shell: bash + - uses: actions/upload-artifact@master + with: + name: Documentation + path: docs/build/ diff --git a/.github/workflows/sphinx-docs-deploy.yml b/.github/workflows/sphinx-docs-deploy.yml index 27a261d..3c483f5 100644 --- a/.github/workflows/sphinx-docs-deploy.yml +++ b/.github/workflows/sphinx-docs-deploy.yml @@ -1,4 +1,4 @@ -name: Deploy mkdocs +name: Deploy Sphinx Docs on: push: @@ -9,10 +9,28 @@ jobs: sphinx-check: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 - - uses: ammaraskar/sphinx-action@master - with: - # git is required to clone the docs theme - # before custom requirement are resolved https://github.com/ammaraskar/sphinx-action/issues/16 - pre-build-command: "apt-get update -y && apt-get install -y git && pip install -r docs/requirements.txt" - docs-folder: "docs/" \ No newline at end of file + - uses: actions/checkout@master + - uses: ammaraskar/sphinx-action@master + with: + # git is required to clone the docs theme + # before custom requirement are resolved https://github.com/ammaraskar/sphinx-action/issues/16 + pre-build-command: "sudo apt-get update -y && sudo apt-get install -y git && pip install -r docs/requirements.txt" + build-command: "sphinx-build -b html source build" + docs-folder: "docs/" + - name: Deploy Documentation + uses: ad-m/github-push-action@master + with: + branch: gh-pages + directory: master + force: true + # run: | + # # First run the same pipeline as Read-The-Docs + # sudo apt-get install python3-sphinx + # sudo apt-get install -y texlive-latex-extra dvipng texlive-pictures + # sudo apt-get install -y cmake + # pip install . + # pip install -r docs/requirements.txt + # cd docs + # make html + # shell: bash + # - name: diff --git a/.gitignore b/.gitignore index bc21cbe..76226be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Files *.DS_Store *.vscode +*.idea *.vs .vscode # dotenv diff --git a/docs/index.rst b/docs/index.rst index eb05675..bf6f812 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -4,14 +4,12 @@ contain the root `toctree` directive. Quickvision API -======================================= +=============== .. toctree:: :maxdepth: 2 :caption: Contents: - modules - Indices and tables ================== diff --git a/docs/conf.py b/docs/source/conf.py similarity index 100% rename from docs/conf.py rename to docs/source/conf.py diff --git a/docs/source/setup.rst b/docs/source/setup.rst deleted file mode 100644 index 552eb49..0000000 --- a/docs/source/setup.rst +++ /dev/null @@ -1,7 +0,0 @@ -setup module -============ - -.. automodule:: setup - :members: - :undoc-members: - :show-inheritance: diff --git a/quickvision/models/classification/cnn/__init__.py b/quickvision/models/classification/cnn/__init__.py index 5b2a5ec..870a485 100644 --- a/quickvision/models/classification/cnn/__init__.py +++ b/quickvision/models/classification/cnn/__init__.py @@ -7,7 +7,6 @@ sanity_fit, ) from quickvision.models.classification.cnn.model_factory import ( - create_timm_cnn, vision_cnn, create_vision_cnn, ) diff --git a/quickvision/models/classification/cnn/model_factory.py b/quickvision/models/classification/cnn/model_factory.py index 7219841..f6f9f84 100644 --- a/quickvision/models/classification/cnn/model_factory.py +++ b/quickvision/models/classification/cnn/model_factory.py @@ -2,29 +2,11 @@ # We will remove the Linear Layer and create a new Linear Layer with num_classes # Port from pytorch_cnn_trainer https://github.com/oke-aditya/pytorch_cnn_trainer -import timm import torchvision from quickvision.models import components import torch.nn as nn -__all__ = ["create_timm_cnn", "vision_cnn", "create_vision_cnn"] - - -def create_timm_cnn(model_name: str, num_classes: int, - in_channels: int = 3, pretrained: bool = True,): - - """ - Creates a model from PyTorch Image Models repository. - To know which models are supported print(timm.list_models()) - Args: - model_name (str) : Name of the model. E.g. efficientnet_b3 - num_classes (int) : Number of classes for classification. - in_channels (int) : Defualt 3. Number of channels of images, 1 for grayscale, 3 for RGB - pretrained (bool) : If true uses modelwweights pretrained on ImageNet. - """ - model = timm.create_model(model_name, pretrained=pretrained, num_classes=num_classes, - in_chans=in_channels,) - return model +__all__ = ["vision_cnn", "create_vision_cnn"] class vision_cnn(nn.Module): diff --git a/requirements.txt b/requirements.txt index 7e93706..cf3733c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ -timm pytorch_lightning scipy diff --git a/tests/test_cnn.py b/tests/test_cnn.py index edf5182..eb34d84 100644 --- a/tests/test_cnn.py +++ b/tests/test_cnn.py @@ -28,11 +28,6 @@ class ModelFactoryTester(unittest.TestCase): - def test_create_timm_cnn(self): - for model_name in supported_timm_models: - model = cnn.create_timm_cnn(model_name, 10, pretrained=None) - self.assertTrue(isinstance(model, nn.Module)) - def test_vision_cnn(self): for model_name in supported_tv_models: model = cnn.vision_cnn(model_name, 10, pretrained=None)