supervisely 6.73.299__py3-none-any.whl → 6.73.300__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of supervisely might be problematic. Click here for more details.
- supervisely/nn/inference/inference.py +91 -0
- {supervisely-6.73.299.dist-info → supervisely-6.73.300.dist-info}/METADATA +1 -1
- {supervisely-6.73.299.dist-info → supervisely-6.73.300.dist-info}/RECORD +7 -7
- {supervisely-6.73.299.dist-info → supervisely-6.73.300.dist-info}/LICENSE +0 -0
- {supervisely-6.73.299.dist-info → supervisely-6.73.300.dist-info}/WHEEL +0 -0
- {supervisely-6.73.299.dist-info → supervisely-6.73.300.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.299.dist-info → supervisely-6.73.300.dist-info}/top_level.txt +0 -0
|
@@ -670,6 +670,56 @@ class Inference:
|
|
|
670
670
|
self.update_gui(self._model_served)
|
|
671
671
|
self.gui.show_deployed_model_info(self)
|
|
672
672
|
|
|
673
|
+
def load_custom_checkpoint(self, model_files: dict, model_meta: dict, device: str = "cuda"):
|
|
674
|
+
"""
|
|
675
|
+
Loads local custom model checkpoint.
|
|
676
|
+
|
|
677
|
+
:param: model_files: dict with paths to model files
|
|
678
|
+
:type: model_files: dict
|
|
679
|
+
:param: model_meta: dict with model meta
|
|
680
|
+
:type: model_meta: dict
|
|
681
|
+
:param: device: device to load model on
|
|
682
|
+
:type: device: str
|
|
683
|
+
:return: None
|
|
684
|
+
:rtype: None
|
|
685
|
+
|
|
686
|
+
:Usage Example:
|
|
687
|
+
|
|
688
|
+
.. code-block:: python
|
|
689
|
+
|
|
690
|
+
model_files = {
|
|
691
|
+
"checkpoint": "supervisely_integration/serve/best.pth",
|
|
692
|
+
"config": "supervisely_integration/serve/model_config.yml",
|
|
693
|
+
}
|
|
694
|
+
model_meta = sly.json.load_json_file("model_meta.json")
|
|
695
|
+
|
|
696
|
+
model.load_custom_checkpoint(model_files, model_meta)
|
|
697
|
+
"""
|
|
698
|
+
|
|
699
|
+
checkpoint = model_files.get("checkpoint")
|
|
700
|
+
if checkpoint is None:
|
|
701
|
+
raise ValueError("Model checkpoint is not provided")
|
|
702
|
+
checkpoint_name = sly_fs.get_file_name_with_ext(model_files["checkpoint"])
|
|
703
|
+
|
|
704
|
+
self.checkpoint_info = CheckpointInfo(
|
|
705
|
+
checkpoint_name=checkpoint_name,
|
|
706
|
+
model_name=None,
|
|
707
|
+
architecture=None,
|
|
708
|
+
checkpoint_url=None,
|
|
709
|
+
custom_checkpoint_path=None,
|
|
710
|
+
model_source=ModelSource.CUSTOM,
|
|
711
|
+
)
|
|
712
|
+
|
|
713
|
+
deploy_params = {
|
|
714
|
+
"model_source": ModelSource.CUSTOM,
|
|
715
|
+
"model_files": model_files,
|
|
716
|
+
"model_info": {},
|
|
717
|
+
"device": device,
|
|
718
|
+
"runtime": RuntimeType.PYTORCH,
|
|
719
|
+
}
|
|
720
|
+
self._set_model_meta_custom_model({"model_meta": model_meta})
|
|
721
|
+
self._load_model(deploy_params)
|
|
722
|
+
|
|
673
723
|
def _load_model_headless(
|
|
674
724
|
self,
|
|
675
725
|
model_files: dict,
|
|
@@ -959,6 +1009,47 @@ class Inference:
|
|
|
959
1009
|
else:
|
|
960
1010
|
return self._inference_one_by_one_wrapper(source, settings)
|
|
961
1011
|
|
|
1012
|
+
def inference(
|
|
1013
|
+
self,
|
|
1014
|
+
source: Union[str, int, np.ndarray, List[str], List[int], List[np.ndarray]],
|
|
1015
|
+
settings: dict = None,
|
|
1016
|
+
) -> Union[Annotation, List[Annotation], dict, List[dict]]:
|
|
1017
|
+
"""
|
|
1018
|
+
Inference method for images. Provide image path or numpy array of image.
|
|
1019
|
+
|
|
1020
|
+
:param: source: image path,image id, numpy array of image or list of image paths, image ids or numpy arrays
|
|
1021
|
+
:type: source: Union[str, int, np.ndarray, List[str], List[int], List[np.ndarray]]
|
|
1022
|
+
:param: settings: inference settings
|
|
1023
|
+
:type: settings: dict
|
|
1024
|
+
:return: annotation or list of annotations
|
|
1025
|
+
:rtype: Union[Annotation, List[Annotation], dict, List[dict]]
|
|
1026
|
+
|
|
1027
|
+
:Usage Example:
|
|
1028
|
+
|
|
1029
|
+
.. code-block:: python
|
|
1030
|
+
|
|
1031
|
+
image_path = "/root/projects/demo/img/sample.jpg"
|
|
1032
|
+
ann = model.inference(image_path)
|
|
1033
|
+
"""
|
|
1034
|
+
input_is_list = True
|
|
1035
|
+
if not isinstance(source, list):
|
|
1036
|
+
input_is_list = False
|
|
1037
|
+
source = [source]
|
|
1038
|
+
|
|
1039
|
+
if settings is None:
|
|
1040
|
+
settings = self._get_inference_settings({})
|
|
1041
|
+
|
|
1042
|
+
if isinstance(source[0], int):
|
|
1043
|
+
ann_jsons = self._inference_batch_ids(
|
|
1044
|
+
self.api, {"batch_ids": source, "settings": settings}
|
|
1045
|
+
)
|
|
1046
|
+
anns = [Annotation.from_json(ann_json, self.model_meta) for ann_json in ann_jsons]
|
|
1047
|
+
else:
|
|
1048
|
+
anns, _ = self._inference_auto(source, settings)
|
|
1049
|
+
if not input_is_list:
|
|
1050
|
+
return anns[0]
|
|
1051
|
+
return anns
|
|
1052
|
+
|
|
962
1053
|
def _inference_batched_wrapper(
|
|
963
1054
|
self,
|
|
964
1055
|
source: List[Union[str, np.ndarray]],
|
|
@@ -875,7 +875,7 @@ supervisely/nn/benchmark/visualization/widgets/table/__init__.py,sha256=47DEQpj8
|
|
|
875
875
|
supervisely/nn/benchmark/visualization/widgets/table/table.py,sha256=atmDnF1Af6qLQBUjLhK18RMDKAYlxnsuVHMSEa5a-e8,4319
|
|
876
876
|
supervisely/nn/inference/__init__.py,sha256=mtEci4Puu-fRXDnGn8RP47o97rv3VTE0hjbYO34Zwqg,1622
|
|
877
877
|
supervisely/nn/inference/cache.py,sha256=h-pP_7th0ana3oJ75sFfTbead3hdKUvYA8Iq2OXDx3I,31317
|
|
878
|
-
supervisely/nn/inference/inference.py,sha256=
|
|
878
|
+
supervisely/nn/inference/inference.py,sha256=jy45Vya994PhW7g0f4tWsbqqjwBx2H87TTLId508rT8,148139
|
|
879
879
|
supervisely/nn/inference/session.py,sha256=jmkkxbe2kH-lEgUU6Afh62jP68dxfhF5v6OGDfLU62E,35757
|
|
880
880
|
supervisely/nn/inference/video_inference.py,sha256=8Bshjr6rDyLay5Za8IB8Dr6FURMO2R_v7aELasO8pR4,5746
|
|
881
881
|
supervisely/nn/inference/gui/__init__.py,sha256=wCxd-lF5Zhcwsis-wScDA8n1Gk_1O00PKgDviUZ3F1U,221
|
|
@@ -1074,9 +1074,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
1074
1074
|
supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
|
|
1075
1075
|
supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
|
|
1076
1076
|
supervisely_lib/__init__.py,sha256=7-3QnN8Zf0wj8NCr2oJmqoQWMKKPKTECvjH9pd2S5vY,159
|
|
1077
|
-
supervisely-6.73.
|
|
1078
|
-
supervisely-6.73.
|
|
1079
|
-
supervisely-6.73.
|
|
1080
|
-
supervisely-6.73.
|
|
1081
|
-
supervisely-6.73.
|
|
1082
|
-
supervisely-6.73.
|
|
1077
|
+
supervisely-6.73.300.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
1078
|
+
supervisely-6.73.300.dist-info/METADATA,sha256=xhJBsSS_qNwfHrlZ3okP6SzD_J8NkxmLyDNvOaAH10A,33573
|
|
1079
|
+
supervisely-6.73.300.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
1080
|
+
supervisely-6.73.300.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
|
|
1081
|
+
supervisely-6.73.300.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
|
|
1082
|
+
supervisely-6.73.300.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|