-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add torchvision detector support (#486)
* add torchvision detector support * add test config files for torchvision models * update notebook * add TorchVisionDetectionModel * add torchvision to automodel * add torchvision demo url, update versions in readme * fix linting
- Loading branch information
Showing
8 changed files
with
604 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# OBSS SAHI Tool | ||
# Code written by Kadir Nar, 2022. | ||
|
||
|
||
from packaging import version | ||
|
||
from sahi.utils.import_utils import _torchvision_available, _torchvision_version, is_available | ||
|
||
|
||
class TorchVisionTestConstants: | ||
FASTERRCNN_CONFIG_PATH = "tests/data/models/torchvision/fasterrcnn_resnet50_fpn.yaml" | ||
SSD300_CONFIG_PATH = "tests/data/models/torchvision/ssd300_vgg16.yaml" | ||
|
||
|
||
if _torchvision_available: | ||
import torchvision | ||
|
||
MODEL_NAME_TO_CONSTRUCTOR = { | ||
"fasterrcnn_resnet50_fpn": torchvision.models.detection.fasterrcnn_resnet50_fpn, | ||
"fasterrcnn_mobilenet_v3_large_fpn": torchvision.models.detection.fasterrcnn_mobilenet_v3_large_fpn, | ||
"fasterrcnn_mobilenet_v3_large_320_fpn": torchvision.models.detection.fasterrcnn_mobilenet_v3_large_320_fpn, | ||
"retinanet_resnet50_fpn": torchvision.models.detection.retinanet_resnet50_fpn, | ||
"ssd300_vgg16": torchvision.models.detection.ssd300_vgg16, | ||
"ssdlite320_mobilenet_v3_large": torchvision.models.detection.ssdlite320_mobilenet_v3_large, | ||
} | ||
|
||
# fcos requires torchvision >= 0.12.0 | ||
if version.parse(_torchvision_version) >= version.parse("0.12.0"): | ||
MODEL_NAME_TO_CONSTRUCTOR["fcos_resnet50_fpn"] = (torchvision.models.detection.fcos_resnet50_fpn,) | ||
|
||
|
||
COCO_CLASSES = [ | ||
"__background__", | ||
"person", | ||
"bicycle", | ||
"car", | ||
"motorcycle", | ||
"airplane", | ||
"bus", | ||
"train", | ||
"truck", | ||
"boat", | ||
"traffic light", | ||
"fire hydrant", | ||
"N/A", | ||
"stop sign", | ||
"parking meter", | ||
"bench", | ||
"bird", | ||
"cat", | ||
"dog", | ||
"horse", | ||
"sheep", | ||
"cow", | ||
"elephant", | ||
"bear", | ||
"zebra", | ||
"giraffe", | ||
"N/A", | ||
"backpack", | ||
"umbrella", | ||
"N/A", | ||
"N/A", | ||
"handbag", | ||
"tie", | ||
"suitcase", | ||
"frisbee", | ||
"skis", | ||
"snowboard", | ||
"sports ball", | ||
"kite", | ||
"baseball bat", | ||
"baseball glove", | ||
"skateboard", | ||
"surfboard", | ||
"tennis racket", | ||
"bottle", | ||
"N/A", | ||
"wine glass", | ||
"cup", | ||
"fork", | ||
"knife", | ||
"spoon", | ||
"bowl", | ||
"banana", | ||
"apple", | ||
"sandwich", | ||
"orange", | ||
"broccoli", | ||
"carrot", | ||
"hot dog", | ||
"pizza", | ||
"donut", | ||
"cake", | ||
"chair", | ||
"couch", | ||
"potted plant", | ||
"bed", | ||
"N/A", | ||
"dining table", | ||
"N/A", | ||
"N/A", | ||
"toilet", | ||
"N/A", | ||
"tv", | ||
"laptop", | ||
"mouse", | ||
"remote", | ||
"keyboard", | ||
"cell phone", | ||
"microwave", | ||
"oven", | ||
"toaster", | ||
"sink", | ||
"refrigerator", | ||
"N/A", | ||
"book", | ||
"clock", | ||
"vase", | ||
"scissors", | ||
"teddy bear", | ||
"hair drier", | ||
"toothbrush", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
model_name: fasterrcnn_resnet50_fpn | ||
num_classes: 91 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
model_name: ssd300_vgg16 | ||
num_classes: 91 |
Oops, something went wrong.