All Projects → prabhuomkar → Pytorch Cpp

prabhuomkar / Pytorch Cpp

Licence: mit
C++ Implementation of PyTorch Tutorials for Everyone

Programming Languages

cplusplus
227 projects

Projects that are alternatives of or similar to Pytorch Cpp

Deep Learning With Pytorch Tutorials
深度学习与PyTorch入门实战视频教程 配套源代码和PPT
Stars: ✭ 1,986 (+95.86%)
Mutual labels:  artificial-intelligence, tutorial, generative-adversarial-network
Awesome Autonomous Vehicle
无人驾驶的资源列表中文版
Stars: ✭ 389 (-61.64%)
Mutual labels:  datasets, tutorial
Start Machine Learning In 2020
A complete guide to start and improve in machine learning (ML), artificial intelligence (AI) in 2021 without ANY background in the field and stay up-to-date with the latest news and state-of-the-art techniques!
Stars: ✭ 357 (-64.79%)
Mutual labels:  artificial-intelligence, tutorial
Cool Fashion Papers
👔👗🕶️🎩 Cool resources about Fashion + AI! (papers, datasets, workshops, companies, ...) (constantly updating)
Stars: ✭ 464 (-54.24%)
Mutual labels:  artificial-intelligence, generative-adversarial-network
Generative models tutorial with demo
Generative Models Tutorial with Demo: Bayesian Classifier Sampling, Variational Auto Encoder (VAE), Generative Adversial Networks (GANs), Popular GANs Architectures, Auto-Regressive Models, Important Generative Model Papers, Courses, etc..
Stars: ✭ 276 (-72.78%)
Mutual labels:  tutorial, generative-adversarial-network
Trankit
Trankit is a Light-Weight Transformer-based Python Toolkit for Multilingual Natural Language Processing
Stars: ✭ 311 (-69.33%)
Mutual labels:  artificial-intelligence, language-model
Tensorflow Tutorial
Tensorflow tutorial from basic to hard, 莫烦Python 中文AI教学
Stars: ✭ 4,122 (+306.51%)
Mutual labels:  tutorial, generative-adversarial-network
Echotorch
A Python toolkit for Reservoir Computing and Echo State Network experimentation based on pyTorch. EchoTorch is the only Python module available to easily create Deep Reservoir Computing models.
Stars: ✭ 231 (-77.22%)
Mutual labels:  artificial-intelligence, torch
Pytorch Cyclegan
A clean and readable Pytorch implementation of CycleGAN
Stars: ✭ 558 (-44.97%)
Mutual labels:  artificial-intelligence, generative-adversarial-network
Easypr
An easy, flexible, and accurate plate recognition project for Chinese licenses in unconstrained situations.
Stars: ✭ 6,046 (+496.25%)
Mutual labels:  artificial-intelligence, datasets
Gans In Action
Companion repository to GANs in Action: Deep learning with Generative Adversarial Networks
Stars: ✭ 748 (-26.23%)
Mutual labels:  artificial-intelligence, generative-adversarial-network
Generative Adversarial Networks
Tutorial on GANs
Stars: ✭ 275 (-72.88%)
Mutual labels:  tutorial, generative-adversarial-network
gans-collection.torch
Torch implementation of various types of GAN (e.g. DCGAN, ALI, Context-encoder, DiscoGAN, CycleGAN, EBGAN, LSGAN)
Stars: ✭ 53 (-94.77%)
Mutual labels:  torch, generative-adversarial-network
Ai Simplest Network
The simplest form of an artificial neural network explained and demonstrated.
Stars: ✭ 333 (-67.16%)
Mutual labels:  artificial-intelligence, tutorial
Artificial Intelligence Deep Learning Machine Learning Tutorials
A comprehensive list of Deep Learning / Artificial Intelligence and Machine Learning tutorials - rapidly expanding into areas of AI/Deep Learning / Machine Vision / NLP and industry specific areas such as Climate / Energy, Automotives, Retail, Pharma, Medicine, Healthcare, Policy, Ethics and more.
Stars: ✭ 2,966 (+192.5%)
Mutual labels:  artificial-intelligence, torch
Fast Srgan
A Fast Deep Learning Model to Upsample Low Resolution Videos to High Resolution at 30fps
Stars: ✭ 417 (-58.88%)
Mutual labels:  artificial-intelligence, generative-adversarial-network
Basic reinforcement learning
An introductory series to Reinforcement Learning (RL) with comprehensive step-by-step tutorials.
Stars: ✭ 826 (-18.54%)
Mutual labels:  artificial-intelligence, tutorial
Gan Sandbox
Vanilla GAN implemented on top of keras/tensorflow enabling rapid experimentation & research. Branches correspond to implementations of stable GAN variations (i.e. ACGan, InfoGAN) and other promising variations of GANs like conditional and Wasserstein.
Stars: ✭ 210 (-79.29%)
Mutual labels:  artificial-intelligence, generative-adversarial-network
Aidl kb
A Knowledge Base for the FB Group Artificial Intelligence and Deep Learning (AIDL)
Stars: ✭ 219 (-78.4%)
Mutual labels:  artificial-intelligence, datasets
Lightweight Gan
Implementation of 'lightweight' GAN, proposed in ICLR 2021, in Pytorch. High resolution image generations that can be trained within a day or two
Stars: ✭ 539 (-46.84%)
Mutual labels:  artificial-intelligence, generative-adversarial-network

C++ Implementation of PyTorch Tutorials for Everyone

OS (Compiler)\LibTorch 1.8.0 nightly
macOS (clang 9.1) Status
macOS (clang 10.0) Status
macOS (clang 11.0) Status
Linux (gcc 5) Status
Linux (gcc 6) Status
Linux (gcc 7) Status
Linux (gcc 8) Status
Windows (msvc 2017) Status

Table of Contents

This repository provides tutorial code in C++ for deep learning researchers to learn PyTorch (i.e. Section 1 to 3)
Python Tutorial: https://github.com/yunjey/pytorch-tutorial

1. Basics

2. Intermediate

3. Advanced

4. Interactive Tutorials

5. Other Popular Tutorials

Getting Started

Requirements

  1. C++
  2. CMake (minimum version 3.14)
  3. LibTorch v1.8.0
  4. Conda

For Interactive Tutorials

Note: Interactive Tutorials are currently running on LibTorch Nightly Version.
So there are some tutorials which can break when working with nightly version.

conda create --name pytorch-cpp
conda activate pytorch-cpp
conda install xeus-cling notebook -c conda-forge

Clone, build and run tutorials

In Google Colab

Open In Colab

On Local Machine

git clone https://github.com/prabhuomkar/pytorch-cpp.git
cd pytorch-cpp

Generate build system

cmake -B build #<options>

Note for Windows users:
Libtorch only supports 64bit Windows and an x64 generator needs to be specified. For Visual Studio this can be done by appending -A x64 to the above command.

Some useful options:

Option Default Description
-D CUDA_V=(|10.2|11.1|none) none Download LibTorch for a CUDA version (none = download CPU version).
-D DOWNLOAD_DATASETS=(OFF|ON) ON Download required datasets during build (only if they do not already exist in pytorch-cpp/data).
-D CREATE_SCRIPTMODULES=(OFF|ON) OFF Create all required scriptmodule files for prelearned models / weights during build. Requires installed python3 with pytorch and torchvision.
-D CMAKE_PREFIX_PATH=path/to/libtorch/share/cmake/Torch <empty> Skip the downloading of LibTorch and use your own local version (see Requirements) instead.
-D CMAKE_BUILD_TYPE=(Release|Debug) <empty> (Release when downloading LibTorch on Windows) Set the build type (Release = compile with optimizations).
Example Linux
Aim
  • Use existing Python, PyTorch (see Requirements) and torchvision installation.
  • Download all datasets and create all necessary scriptmodule files.
Command
cmake -B build \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_PREFIX_PATH=/path/to/libtorch/share/cmake/Torch \
-D CREATE_SCRIPTMODULES=ON 
Example Windows
Aim
  • Automatically download LibTorch for CUDA 11.1 and all necessary datasets.
  • Do not create scriptmodule files.
Command
cmake -B build \
-A x64 \
-D CUDA_V=11.1

Build

Note for Windows (Visual Studio) users:
The CMake script downloads the Release version of LibTorch, so --config Release has to be appended to the build command.

How dataset download and scriptmodule creation work:

  • If DOWNLOAD_DATASETS is ON, the datasets required by the tutorials you choose to build will be downloaded to pytorch-cpp/data (if they do not already exist there).
  • If CREATE_SCRIPTMODULES is ON, the scriptmodule files for the prelearned models / weights required by the tutorials you choose to build will be created in the model folder of the respective tutorial's source folder (if they do not already exist).

All tutorials

To build all tutorials use

cmake --build build

All tutorials in a category

You can choose to only build tutorials in one of the categories basics, intermediate, advanced or popular. For example, if you are only interested in the basics tutorials:

cmake --build build --target basics
# In general: cmake --build build --target {category}

Single tutorial

You can also choose to only build a single tutorial. For example to build the language model tutorial only:

cmake --build build --target language-model
# In general: cmake --build build --target {tutorial-name}

Note:
The target argument is the tutorial's foldername with all underscores replaced by hyphens.

Tip for users of CMake version >= 3.15:
You can specify several targets separated by spaces, for example:

cmake --build build --target language-model image-captioning

Run Tutorials

  1. (IMPORTANT!) First change into the tutorial's directory within build/tutorials. For example, assuming you are in the pytorch-cpp directory and want to change to the pytorch basics tutorial folder:
    cd build/tutorials/basics/pytorch_basics
    # In general: cd build/tutorials/{basics|intermediate|advanced|popular/blitz}/{tutorial_name}
    
  2. Run the executable. Note that the executable's name is the tutorial's foldername with all underscores replaced with hyphens (e.g. for tutorial folder: pytorch_basics -> executable name: pytorch-basics (or pytorch-basics.exe on Windows)). For example, to run the pytorch basics tutorial:

    Linux/Mac
    ./pytorch-basics
    # In general: ./{tutorial-name}
    
    Windows
    .\pytorch-basics.exe
    # In general: .\{tutorial-name}.exe
    

Using Docker

Find the latest and previous version images on Docker Hub.

You can build and run the tutorials (on CPU) in a Docker container using the provided Dockerfile and docker-compose.yml files:

  1. From the root directory of the cloned repo build the image:
    docker-compose build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)
    

    Note:
    When you run the Docker container, the host repo directory is mounted as a volume in the Docker container in order to cache build and downloaded dependency files so that it is not necessary to rebuild or redownload everything when a container is restarted. In order to have correct file permissions it is necessary to provide your user and group ids as build arguments when building the image on Linux.

  2. Now start the container and build the tutorials using:
    docker-compose run --rm pytorch-cpp
    
    This fetches all necessary dependencies and builds all tutorials. After the build is done, by default the container starts bash in interactive mode in the build/tutorials folder.
    As with the local build, you can choose to only build tutorials of a category (basics, intermediate, advanced, popular):
    docker-compose run --rm pytorch-cpp {category}
    
    In this case the container is started in the chosen category's base build directory.
    Alternatively, you can also directly run a tutorial by instead invoking the run command with a tutorial name as additional argument, for example:
    docker-compose run --rm pytorch-cpp pytorch-basics
    # In general: docker-compose run --rm pytorch-cpp {tutorial-name} 
    
    This will - if necessary - build the pytorch-basics tutorial and then start the executable in a container.

License

This repository is licensed under MIT as given in LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].