Skip to content

Commit

Permalink
remove layer support (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
fcakyon committed Oct 26, 2022
1 parent 030bd61 commit d589f22
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 138 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ jobs:
run: >
pip install transformers==4.22.1
- name: Install Layer (0.10.*)
run: >
pip install -U "layer>=0.10.0,<0.11.0"
- name: Install pycocotools(2.0.5)
run: >
pip install pycocotools==2.0.5
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/ci_torch1.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ jobs:
run: >
pip install transformers==4.21.2
- name: Install Layer (0.10.*)
if: >
matrix.python-version != '3.6'
run: >
pip install -U "layer>=0.10.0,<0.11.0"
- name: Install pycocotools(2.0.5)
run: >
pip install pycocotools==2.0.5
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/package_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ jobs:
run: >
pip install transformers==4.22.1
- name: Install Layer (0.10.*)
if: >
matrix.python-version != '3.6'
run: >
pip install -U "layer>=0.10.0,<0.11.0"
- name: Install pycocotools(2.0.5)
run: >
pip install pycocotools==2.0.5
Expand Down
1 change: 0 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ Print related package versions in the current env as:
06/19/2022 21:24:52 - INFO - sahi.utils.import_utils - detectron2 version 0.6+cpu is available.
06/19/2022 21:24:52 - INFO - sahi.utils.import_utils - transformers version 4.20.0 is available.
06/19/2022 21:24:52 - INFO - sahi.utils.import_utils - timm version 0.4.12 is available.
06/19/2022 21:24:52 - INFO - sahi.utils.import_utils - layer version 0.10.2510447650 is available.
06/19/2022 21:24:52 - INFO - sahi.utils.import_utils - fiftyone version 0.14.2 is available.
06/19/2022 21:24:52 - INFO - sahi.utils.import_utils - norfair version 1.0.0 is available.
```
Expand Down
63 changes: 1 addition & 62 deletions sahi/auto_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def from_pretrained(
model_type: str
Name of the detection framework (example: "yolov5", "mmdet", "detectron2")
model_path: str
Path of the Layer model (ex. '/sahi/yolo/models/yolov5')
Path of the detection model (ex. 'model.pt')
config_path: str
Path of the config file (ex. 'mmdet/configs/cascade_rcnn_r50_fpn_1x.py')
device: str
Expand Down Expand Up @@ -74,64 +74,3 @@ def from_pretrained(
image_size=image_size,
**kwargs,
)

@staticmethod
def from_layer(
model_path: str,
no_cache: bool = False,
device: Optional[str] = None,
mask_threshold: float = 0.5,
confidence_threshold: float = 0.3,
category_mapping: Optional[Dict] = None,
category_remapping: Optional[Dict] = None,
image_size: int = None,
):
"""
Loads a DetectionModel from Layer. You can pass additional parameters in the name to retrieve a specific version
of the model with format: ``model_path:major_version.minor_version``
By default, this function caches models locally when possible.
Args:
model_path: str
Path of the Layer model (ex. '/sahi/yolo/models/yolov5')
no_cache: bool
If True, force model fetch from the remote location.
device: str
Device, "cpu" or "cuda:0"
mask_threshold: float
Value to threshold mask pixels, should be between 0 and 1
confidence_threshold: float
All predictions with score < confidence_threshold will be discarded
category_mapping: dict: str to str
Mapping from category id (str) to category name (str) e.g. {"1": "pedestrian"}
category_remapping: dict: str to int
Remap category ids based on category names, after performing inference e.g. {"car": 3}
image_size: int
Inference input size.
Returns:
Returns an instance of a DetectionModel
Raises:
ImportError: If Layer is not installed in your environment
ValueError: If model path does not match expected pattern: organization_name/project_name/models/model_name
"""
check_requirements(["layer"])

import layer

layer_model = layer.get_model(name=model_path, no_cache=no_cache).get_train()
if layer_model.__class__.__module__ in ["yolov5.models.common", "models.common"]:
model_type = "yolov5"
else:
raise Exception(f"Unsupported model: {type(layer_model)}. Only YOLOv5 models are supported.")

model_class_name = MODEL_TYPE_TO_MODEL_CLASS_NAME[model_type]
DetectionModel = import_model_class(model_class_name)

return DetectionModel(
model=layer_model,
device=device,
mask_threshold=mask_threshold,
confidence_threshold=confidence_threshold,
category_mapping=category_mapping,
category_remapping=category_remapping,
image_size=image_size,
)
2 changes: 0 additions & 2 deletions sahi/utils/import_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import contextlib
import importlib.util
import logging
import os
Expand Down Expand Up @@ -48,7 +47,6 @@ def print_enviroment_info():
_detectron2_available, _detectron2_version = get_package_info("detectron2")
_transformers_available, _transformers_version = get_package_info("transformers")
_timm_available, _timm_version = get_package_info("timm")
_layer_available, _layer_version = get_package_info("layer")
_fiftyone_available, _fiftyone_version = get_package_info("fiftyone")
_norfair_available, _norfair_version = get_package_info("norfair")

Expand Down
57 changes: 0 additions & 57 deletions tests/test_layer.py

This file was deleted.

0 comments on commit d589f22

Please sign in to comment.