Skip to content
Permalink
master
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
…#432)

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

* documentation update
- removed stale Transformer_readme.md

* 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 <harshbafna619@gmail.com>
Co-authored-by: dhaniram kshirsagar <dhaniram_kshirsagar@persistent.com>
Co-authored-by: dhaniram-kshirsagar <26479924+dhaniram-kshirsagar@users.noreply.github.com>
Co-authored-by: Henry Tappen <htappen@gmail.com>
Co-authored-by: harshbafna <harsh_bafna@persistent.co.in>
Co-authored-by: Aaqib <maaquib@gmail.com>
22 contributors

Users who have contributed to this file

@harshbafna @dhaniram-kshirsagar @shivamshriwas @maaquib @FrancescoSaverioZuppichini @takp @aaronmarkham @mycpuorg @lanpa @htappen @hephaex @HamidShojanazeri
"""
Module for image segmentation default handler
"""
import torch
from torchvision import transforms as T
from .vision_handler import VisionHandler
class ImageSegmenter(VisionHandler):
"""
ImageSegmenter handler class. This handler takes a batch of images
and returns output shape as [N K H W],
where N - batch size, K - number of classes, H - height and W - width.
"""
image_processing = T.Compose([
T.Resize(256),
T.CenterCrop(224),
T.ToTensor(),
T.Normalize(
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]
)])
def postprocess(self, data):
# Returning the class for every pixel makes the response size too big
# (> 24mb). Instead, we'll only return the top class for each image
data = data['out']
data = torch.nn.functional.softmax(data, dim=1)
data = torch.max(data, dim=1)
data = torch.stack([data.indices.type(data.values.dtype), data.values], dim=3)
return data.tolist()