Giter Club home page Giter Club logo

computervision-recipes's Introduction

+ Update July: Added support for action recognition and tracking
+              in the new release v1.2.

Computer Vision

In recent years, we've see an extra-ordinary growth in Computer Vision, with applications in face recognition, image understanding, search, drones, mapping, semi-autonomous and autonomous vehicles. A key part to many of these applications are visual recognition tasks such as image classification, object detection and image similarity.

This repository provides examples and best practice guidelines for building computer vision systems. The goal of this repository is to build a comprehensive set of tools and examples that leverage recent advances in Computer Vision algorithms, neural architectures, and operationalizing such systems. Rather than creating implementations from scratch, we draw from existing state-of-the-art libraries and build additional utility around loading image data, optimizing and evaluating models, and scaling up to the cloud. In addition, having worked in this space for many years, we aim to answer common questions, point out frequently observed pitfalls, and show how to use the cloud for training and deployment.

We hope that these examples and utilities can significantly reduce the “time to market” by simplifying the experience from defining the business problem to development of solution by orders of magnitude. In addition, the example notebooks would serve as guidelines and showcase best practices and usage of the tools in a wide variety of languages.

These examples are provided as Jupyter notebooks and common utility functions. All examples use PyTorch as the underlying deep learning library.

Examples

This repository supports various Computer Vision scenarios which either operate on a single image:

Some supported CV scenarios

As well as scenarios such as action recognition which take a video sequence as input:

Target Audience

Our target audience for this repository includes data scientists and machine learning engineers with varying levels of Computer Vision knowledge as our content is source-only and targets custom machine learning modelling. The utilities and examples provided are intended to be solution accelerators for real-world vision problems.

Getting Started

To get started, navigate to the Setup Guide, which lists instructions on how to setup the compute environment and dependencies needed to run the notebooks in this repo. Once your environment is setup, navigate to the Scenarios folder and start exploring the notebooks. We recommend to start with the image classification notebooks, since this introduces concepts which are also used by the other scenarios (e.g. pre-training on ImageNet).

Alternatively, we support Binder Binder which makes it easy to try one of our notebooks in a web-browser simply by following this link. However, Binder is free, and as a result only comes with limited CPU compute power and without GPU support. Expect the notebook to run very slowly (this is somewhat improved by reducing image resolution to e.g. 60 pixels but at the cost of low accuracies).

Scenarios

The following is a summary of commonly used Computer Vision scenarios that are covered in this repository. For each of the main scenarios ("base"), we provide the tools to effectively build your own model. This includes simple tasks such as fine-tuning your own model on your own data, to more complex tasks such as hard-negative mining and even model deployment.

Scenario Support Description
Classification Base Image Classification is a supervised machine learning technique to learn and predict the category of a given image.
Similarity Base Image Similarity is a way to compute a similarity score given a pair of images. Given an image, it allows you to identify the most similar image in a given dataset.
Detection Base Object Detection is a technique that allows you to detect the bounding box of an object within an image.
Keypoints Base Keypoint detection can be used to detect specific points on an object. A pre-trained model is provided to detect body joints for human pose estimation.
Segmentation Base Image Segmentation assigns a category to each pixel in an image.
Action recognition Base Action recognition to identify in video/webcam footage what actions are performed (e.g. "running", "opening a bottle") and at what respective start/end times. We also implemented the i3d implementation of action recognition that can be found under (contrib)[contrib].
Tracking Base Tracking allows to detect and track multiple objects in a video sequence over time.
Crowd counting Contrib Counting the number of people in low-crowd-density (e.g. less than 10 people) and high-crowd-density (e.g. thousands of people) scenarios.

We separate the supported CV scenarios into two locations: (i) base: code and notebooks within the "utils_cv" and "scenarios" folders which follow strict coding guidelines, are well tested and maintained; (ii) contrib: code and other assets within the "contrib" folder, mainly covering less common CV scenarios using bleeding edge state-of-the-art approaches. Code in "contrib" is not regularly tested or maintained.

Computer Vision on Azure

Note that for certain computer vision problems, you may not need to build your own models. Instead, pre-built or easily customizable solutions exist on Azure which do not require any custom coding or machine learning expertise. We strongly recommend evaluating if these can sufficiently solve your problem. If these solutions are not applicable, or the accuracy of these solutions is not sufficient, then resorting to more complex and time-consuming custom approaches may be necessary.

The following Microsoft services offer simple solutions to address common computer vision tasks:

  • Vision Services are a set of pre-trained REST APIs which can be called for image tagging, face recognition, OCR, video analytics, and more. These APIs work out of the box and require minimal expertise in machine learning, but have limited customization capabilities. See the various demos available to get a feel for the functionality (e.g. Computer Vision). The service can be used through API calls or through SDKs (available in .NET, Python, Java, Node and Go languages)

  • Custom Vision is a SaaS service to train and deploy a model as a REST API given a user-provided training set. All steps including image upload, annotation, and model deployment can be performed using an intuitive UI or through SDKs (available in .NEt, Python, Java, Node and Go languages). Training image classification or object detection models can be achieved with minimal machine learning expertise. The Custom Vision offers more flexibility than using the pre-trained cognitive services APIs, but requires the user to bring and annotate their own data.

If you need to train your own model, the following services and links provide additional information that is likely useful.

  • Azure Machine Learning service (AzureML) is a service that helps users accelerate the training and deploying of machine learning models. While not specific for computer vision workloads, the AzureML Python SDK can be used for scalable and reliable training and deployment of machine learning solutions to the cloud. We leverage Azure Machine Learning in several of the notebooks within this repository (e.g. deployment to Azure Kubernetes Service)

  • Azure AI Reference architectures provide a set of examples (backed by code) of how to build common AI-oriented workloads that leverage multiple cloud components. While not computer vision specific, these reference architectures cover several machine learning workloads such as model deployment or batch scoring.

Build Status

AzureML Testing

Build Type Branch Status Branch Status
Linux GPU master Build Status staging Build Status
Linux CPU master Build Status staging Build Status
Notebook unit GPU master Build Status staging Build Status

Contributing

This project welcomes contributions and suggestions. Please see our contribution guidelines.

computervision-recipes's People

Contributors

aashnamsft avatar angusrtaylor avatar anupammicrosoft avatar ateste avatar bethz avatar ehrlinger avatar gramhagen avatar heatherbshapiro avatar jainr avatar jiata avatar jreynolds01 avatar karineip avatar loomlike avatar lovigano avatar lucasavila00 avatar mcboyd avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar miguelgfierro avatar msftgits avatar patrickbue avatar sharatsc avatar simonzhaoms avatar soumyadeep9 avatar soumyadeepdey avatar vapaunic avatar yalaudah avatar yijingchen avatar youngpark avatar yueguoguo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

computervision-recipes's Issues

Feature ISeg: show how create and use custom labelled segmentation dataset

As the title says, the scope is:

  • find a custom unlabelled dataset, or find a labelled dataset and show how to create segmentation labels yourself. Dataset has to have continuity to datasets used in #49 and #47
  • show how to label this dataset (create semantic segmentation labels for each pixel) with a custom smart labelling tool such as http://www.cs.toronto.edu/~amlan/demo/ (polygon RNN)
  • write notebook detailing this work training a simple DNN model for semantic segmentation.

The scope of the work includes using a pre-trained semantic segmentation tool (does not include showing how to train such a tool)

Feature IC: create toy dataset for single-class image classification

E.g. using cans, bottles, and milk boxes.

  • Single-label image classification: single object per image. Maybe also some "negative" images without a single object-of-interest in them.
  • Multi-label image classification: 0 or more objects in image.

Maybe 50 images for each of the two datasets?

[BUG] Test errors in test_default_sweeper_*

tests/unit/test_experiments.py:26:

>           mkdir(name, mode)
E           FileExistsError: [Errno 17] File exists: 'tmp_data'

tests/unit/test_experiments.py:71: AssertionError

>       assert df.mean(level=(2)).loc["fridgeObjects", "accuracy"] > 0.85
E       assert 0.7954545617103577 > 0.85

Feature IC: additional gpu guidance in webcam notebook

In the webcam notebook, we print out the name of the device that will be used to train your model. Would it be possible to provide some guidance, for the users, on:

  • how to know whether their machine has a GPU installed or not
  • what they need to do to get the model to train on the GPU instead of a CPU, if the former is present
  • what to expect if their machine doesn't have a GPU.

Feature ISeg: Compile multiple 2D image segmentation datasets

Compile ~5 image segmentation datasets. Similar to IC, these will be used to find good default parameters, for integration tests, etc.
The datasets should be small since (i) otherwise running parameter tuning takes a long time; and (ii) most customer only have 100s of images, even for image classification.

Feature IC: Find good default parameters

Find default parameteres (e.g. learning rate) which work well for many IC problems, for shallow/deep models, for low/high res image, etc. See CVTK's default parameters table. Uses the internal datasets for single-class and multi-class image classification.

Feature ISeg: Build oil & gas use case notebook

Use the basic notebook in combination with an oil & gas dataset. Tweak parameters to improve accuracy, etc. As a second step, evaluate accuracy improvements using spatial consistency smoothing.

Feature IC: hard-negative mining

Ideally show (at the very least explain) in an example where hard-negative mining makes a big difference. E.g. training a deer classifier, which also fires on trees.

Feature ISeg: AML hyperparameter tuning of segmentation models

TODO: this is a placeholder for hyperparameter tuning. Pending on 2D semantic segmentation and 2D Oil and Gas scenarios, we will see what dataset and model we want to pick for this notebook - but the accent should be on scalable hyperparameter tuning of segmentation models.

Feature IC: document pitfalls and guidelines

  • Examples which are, and which are not suited for image classification and object detection
    • For example:
      • Image classification: area of interest is tiny in the image (e.g. logo far in the background)
      • Object detection: object to be found is hard to define where it starts/ends
  • Annotation
    • How to annotate / how to not annotate
  • Common pitfalls and how to avoid
  • Trade-off speed versus accuracy in training and inference
  • etc.

Add minimum requirements (gpu memory) to notebooks

To use gpu for training, users will need certain size of gpu memory, depending on the image and batch size. Would be good to have minimum requirements to each notebook to use the default parameters shown in the notebook.

I got an gpu memory error while testing the training notebook from my laptop which has a tiny gpu (gtx1050 2g).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.