Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file

* - updated image classifier default handler
- updated custom resnet and mnist handlers
- update docs

* documentation update
- removed stale

* updated docs

* Doc restructure and code fixes

* Updated example as per fix in default handlers

* Enhanced base and custom handler examples

* Missing checking for manifest

* Fixed some typos

* Removed commented code

* Refactor BaseHandler

* Adding in unit tests

* Fixed gitignore in this branch

* Fix a bug with Image Segmenter

* Updated Object Detector to reuse functionality; consistency

* Fix pylint errors

* Backwards compat for index_names.json

* Fixed Image Segmenter again

* Made the compat layer in text actually compat.

* Removed batching from text classifier

* Adding comments per review.

* Fixing doc feedback.

* Updating docs about batching.

* Fixed error introduced due to conflict resolution via web based merge tool

* Corrected code comment

* - Updated Object detection & text classification handlers
- updated docs

* fixed python linting errors

* updated index to name json text classifier

* fixed object detector handler for batch support

* Fixed the batch inference output

* update expected output as per new handler changes

* updated text classification mar name in sanity suite

* updated text classifier mar name and removed bert scripted models

* updated model zoo with new text classification url

* added model_name in while registering model in sanity suite

* updated text classification model name

* added upgrade option for installing python dependencies in install utils

* added upgrade option for installing python dependencies and extra numpy package in regression suite

* refectored pytests in regression suite for better performance and reporting

* minor fix in torch-archiver command

* reverted postprocess removal

* updated mar files in model zoo to use updated handlers

* updated regression suite to use updated mar files

* suppressed pylint warning in UT

* fixed resnet-152 mar name and expected output

* updated inference tests data
- added tolerence value for resent152 models

* Added custom handler in vgg11 example (#559)

* added custom handler for vgg11

* added readme for vgg11 example

* fixed typo in readme

* updated model zoo

* reverted back changes for scripted vgg11 mar file

* added vgg11 model to regression test suite

* disabled pylint check in UT

* updated expected response for vgg11 inference in regression suite

* updated expected response for vgg11 inference in regression suite

* updated expected for densenet scripted

Co-authored-by: Harsh Bafna <>
Co-authored-by: dhaniram kshirsagar <>
Co-authored-by: dhaniram-kshirsagar <>
Co-authored-by: Henry Tappen <>
Co-authored-by: harshbafna <>
Co-authored-by: Aaqib <>
23 contributors

Users who have contributed to this file

@harshbafna @dhaniram-kshirsagar @maaquib @shivamshriwas @FrancescoSaverioZuppichini @takp @TheRochVoices @aaronmarkham @mycpuorg @lanpa @htappen @hephaex
Module for image classification default handler
import torch
import torch.nn.functional as F
from torchvision import transforms
from .vision_handler import VisionHandler
from ..utils.util import map_class_to_label
class ImageClassifier(VisionHandler):
ImageClassifier handler class. This handler takes an image
and returns the name of object in that image.
topk = 5
# These are the standard Imagenet dimensions
# and statistics
image_processing = transforms.Compose([
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
def set_max_result_classes(self, topk):
self.topk = topk
def get_max_result_classes(self):
return self.topk
def postprocess(self, data):
ps = F.softmax(data, dim=1)
probs, classes = torch.topk(ps, self.topk, dim=1)
probs = probs.tolist()
classes = classes.tolist()
return map_class_to_label(probs, self.mapping, classes)