supervisely 6.73.260__py3-none-any.whl → 6.73.261__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.

@@ -19,6 +19,8 @@ from supervisely.app.widgets import (
19
19
  )
20
20
  from supervisely.io.fs import get_file_name_with_ext
21
21
  from supervisely.nn.experiments import ExperimentInfo
22
+ from supervisely.nn.utils import ModelSource
23
+
22
24
 
23
25
  WEIGHTS_DIR = "weights"
24
26
 
@@ -473,6 +475,17 @@ class ExperimentSelector(Widget):
473
475
  full_model_files["checkpoint"] = self.get_selected_checkpoint_path()
474
476
  return full_model_files
475
477
 
478
+ def get_deploy_params(self) -> Dict[str, Any]:
479
+ """
480
+ Returns a dictionary with deploy parameters except runtime and device keys.
481
+ """
482
+ deploy_params = {
483
+ "model_source": ModelSource.CUSTOM,
484
+ "model_files": self.get_model_files(),
485
+ "model_info": self.get_selected_experiment_info(),
486
+ }
487
+ return deploy_params
488
+
476
489
  def set_active_row(self, row_index: int) -> None:
477
490
  if row_index < 0 or row_index > len(self._rows) - 1:
478
491
  raise ValueError(f'Row with index "{row_index}" does not exist')
@@ -1,9 +1,10 @@
1
- from typing import Dict, List, Union
1
+ from typing import Dict, List, Literal, Union
2
2
 
3
3
  from supervisely.api.api import Api
4
4
  from supervisely.app.content import DataJson, StateJson
5
5
  from supervisely.app.widgets import Widget
6
6
  from supervisely.io.fs import get_file_ext
7
+ from supervisely.nn.utils import ModelSource
7
8
 
8
9
 
9
10
  class PretrainedModelsSelector(Widget):
@@ -134,39 +135,71 @@ class PretrainedModelsSelector(Widget):
134
135
  selected_row_index = int(widget_actual_state["selectedRow"])
135
136
  return models[selected_row_index]
136
137
 
137
- def get_selected_model_params(self, model_name_column: str = "Model") -> Union[Dict, None]:
138
+ def get_selected_model_params(
139
+ self,
140
+ model_name_column: str = "Model",
141
+ train_version: Literal["v1", "v2"] = "v1",
142
+ ) -> Union[Dict, None]:
138
143
  selected_model = self.get_selected_row()
139
144
  if selected_model is None:
140
145
  return {}
141
146
 
142
- model_name = selected_model.get(model_name_column)
143
- if model_name is None:
144
- raise ValueError(
145
- "Could not find model name. Make sure you have column 'Model' in your models list."
146
- )
147
- checkpoint_url = selected_model.get("meta", {}).get("weights_url")
148
- if checkpoint_url is None:
149
- pass
150
-
151
- checkpoint_ext = get_file_ext(checkpoint_url)
152
- checkpoint_name = f"{model_name.lower()}{checkpoint_ext}"
153
-
154
- task_type = self.get_selected_task_type()
155
- model_params = {
156
- "model_source": "Pretrained models",
157
- "task_type": task_type,
158
- "checkpoint_name": checkpoint_name,
159
- "checkpoint_url": checkpoint_url,
160
- }
161
-
162
- if len(self._arch_types) > 1:
163
- arch_type = self.get_selected_arch_type()
164
- model_params["arch_type"] = arch_type
165
-
166
- config_url = selected_model.get("meta", {}).get("config_url")
167
- if config_url is not None:
168
- model_params["config_url"] = config_url
147
+ if train_version == "v1":
148
+ model_name = selected_model.get(model_name_column)
149
+ if model_name is None:
150
+ raise ValueError(
151
+ "Could not find model name. Make sure you have column 'Model' in your models list."
152
+ )
153
+
154
+ model_meta = selected_model.get("meta")
155
+ if model_meta is None:
156
+ raise ValueError(
157
+ "Could not find model meta. Make sure you have key 'meta' in your models configuration list."
158
+ )
159
+ checkpoint_url = model_meta.get("weights_url")
160
+ if checkpoint_url is None:
161
+ model_files = model_meta.get("model_files")
162
+ if model_files is None:
163
+ raise ValueError(
164
+ "Could not find model files. Make sure you have key 'model_files' or 'weights_url' in 'meta' in your models configuration list."
165
+ )
166
+ checkpoint_url = model_files.get("checkpoint")
167
+ if checkpoint_url is None:
168
+ raise ValueError(
169
+ "Could not find checkpoint url. Make sure you have key 'checkpoint' in 'model_files' in 'meta' in your models configuration list."
170
+ )
171
+
172
+ checkpoint_ext = get_file_ext(checkpoint_url)
173
+ checkpoint_name = f"{model_name.lower()}{checkpoint_ext}"
174
+
175
+ task_type = self.get_selected_task_type()
176
+ model_params = {
177
+ "model_source": "Pretrained models",
178
+ "task_type": task_type,
179
+ "checkpoint_name": checkpoint_name,
180
+ "checkpoint_url": checkpoint_url,
181
+ }
169
182
 
183
+ if len(self._arch_types) > 1:
184
+ arch_type = self.get_selected_arch_type()
185
+ model_params["arch_type"] = arch_type
186
+
187
+ config_url = selected_model.get("meta", {}).get("config_url")
188
+ if config_url is not None:
189
+ model_params["config_url"] = config_url
190
+ elif train_version == "v2":
191
+ model_info = self.get_selected_row()
192
+ meta = model_info.get("meta")
193
+ if meta is None:
194
+ raise ValueError("key 'meta' not found in model configuration")
195
+ model_files = meta.get("model_files")
196
+ if model_files is None:
197
+ raise ValueError("key 'model_files' not found in key 'meta' in model configuration")
198
+ model_params = {
199
+ "model_source": ModelSource.PRETRAINED,
200
+ "model_info": model_info,
201
+ "model_files": model_files,
202
+ }
170
203
  return model_params
171
204
 
172
205
  def get_selected_row_index(self, state=StateJson()) -> Union[int, None]:
@@ -536,58 +536,62 @@ class BaseTrainArtifacts:
536
536
  api: Api, train_info: TrainInfo
537
537
  ) -> ExperimentInfo:
538
538
 
539
- checkpoints = []
540
- for chk in train_info.checkpoints:
541
- if self.weights_folder:
542
- checkpoints.append(join(self.weights_folder, chk.name))
543
- else:
544
- checkpoints.append(chk.name)
545
-
546
- best_checkpoint = next(
547
- (chk.name for chk in train_info.checkpoints if "best" in chk.name), None
548
- )
549
- if not best_checkpoint and checkpoints:
550
- best_checkpoint = get_file_name_with_ext(checkpoints[-1])
551
-
552
- task_info = api.task.get_info_by_id(train_info.task_id)
553
- workspace_id = task_info["workspaceId"]
554
-
555
- project = api.project.get_info_by_name(workspace_id, train_info.project_name)
556
- project_id = project.id if project else None
557
-
558
- model_files = {}
559
- if train_info.config_path:
560
- model_files["config"] = self.get_config_path(train_info.artifacts_folder).replace(
561
- train_info.artifacts_folder, ""
539
+ try:
540
+ checkpoints = []
541
+ for chk in train_info.checkpoints:
542
+ if self.weights_folder:
543
+ checkpoints.append(join(self.weights_folder, chk.name))
544
+ else:
545
+ checkpoints.append(chk.name)
546
+
547
+ best_checkpoint = next(
548
+ (chk.name for chk in train_info.checkpoints if "best" in chk.name), None
562
549
  )
563
-
564
- input_datetime = task_info["startedAt"]
565
- parsed_datetime = datetime.strptime(input_datetime, "%Y-%m-%dT%H:%M:%S.%fZ")
566
- date_time = parsed_datetime.strftime("%Y-%m-%d %H:%M:%S")
567
-
568
- experiment_info_data = {
569
- "experiment_name": f"Unknown {self.framework_name} experiment",
570
- "framework_name": self.framework_name,
571
- "model_name": f"Unknown {self.framework_name} model",
572
- "task_type": train_info.task_type,
573
- "project_id": project_id,
574
- "task_id": train_info.task_id,
575
- "model_files": model_files,
576
- "checkpoints": checkpoints,
577
- "best_checkpoint": best_checkpoint,
578
- "artifacts_dir": train_info.artifacts_folder,
579
- "datetime": date_time,
580
- }
581
-
582
- experiment_info_fields = {
583
- field.name
584
- for field in ExperimentInfo.__dataclass_fields__.values() # pylint: disable=no-member
585
- }
586
- for field in experiment_info_fields:
587
- if field not in experiment_info_data:
588
- experiment_info_data[field] = None
589
-
590
- return ExperimentInfo(**experiment_info_data)
550
+ if not best_checkpoint and checkpoints:
551
+ best_checkpoint = get_file_name_with_ext(checkpoints[-1])
552
+
553
+ task_info = api.task.get_info_by_id(train_info.task_id)
554
+ workspace_id = task_info["workspaceId"]
555
+
556
+ project = api.project.get_info_by_name(workspace_id, train_info.project_name)
557
+ project_id = project.id if project else None
558
+
559
+ model_files = {}
560
+ if train_info.config_path:
561
+ model_files["config"] = self.get_config_path(
562
+ train_info.artifacts_folder
563
+ ).replace(train_info.artifacts_folder, "")
564
+
565
+ input_datetime = task_info["startedAt"]
566
+ parsed_datetime = datetime.strptime(input_datetime, "%Y-%m-%dT%H:%M:%S.%fZ")
567
+ date_time = parsed_datetime.strftime("%Y-%m-%d %H:%M:%S")
568
+
569
+ experiment_info_data = {
570
+ "experiment_name": f"Unknown {self.framework_name} experiment",
571
+ "framework_name": self.framework_name,
572
+ "model_name": f"Unknown {self.framework_name} model",
573
+ "task_type": train_info.task_type,
574
+ "project_id": project_id,
575
+ "task_id": train_info.task_id,
576
+ "model_files": model_files,
577
+ "checkpoints": checkpoints,
578
+ "best_checkpoint": best_checkpoint,
579
+ "artifacts_dir": train_info.artifacts_folder,
580
+ "datetime": date_time,
581
+ }
582
+
583
+ experiment_info_fields = {
584
+ field.name
585
+ for field in ExperimentInfo.__dataclass_fields__.values() # pylint: disable=no-member
586
+ }
587
+ for field in experiment_info_fields:
588
+ if field not in experiment_info_data:
589
+ experiment_info_data[field] = None
590
+
591
+ return ExperimentInfo(**experiment_info_data)
592
+ except Exception as e:
593
+ logger.warning(f"Failed to build experiment info: {e}")
594
+ return None
591
595
 
592
596
  train_infos = self.get_list(sort)
593
597
 
@@ -571,7 +571,9 @@ class Inference:
571
571
  ) as download_pbar:
572
572
  self.gui.download_progress.show()
573
573
  sly_fs.download(
574
- url=file_url, save_path=file_path, progress=download_pbar.update
574
+ url=file_url,
575
+ save_path=file_path,
576
+ progress=download_pbar.update,
575
577
  )
576
578
  local_model_files[file] = file_path
577
579
  else:
@@ -590,6 +592,10 @@ class Inference:
590
592
  for file in model_files:
591
593
  file_url = model_files[file]
592
594
  file_info = self.api.file.get_info_by_path(team_id, file_url)
595
+ if file_info is None:
596
+ raise FileNotFoundError(
597
+ f"File '{file_url}' not found in Team Files. Make sure the file exists."
598
+ )
593
599
  file_size = file_info.sizeb
594
600
  file_name = os.path.basename(file_url)
595
601
  file_path = os.path.join(self.model_dir, file_name)
@@ -1374,7 +1380,11 @@ class Inference:
1374
1380
  return result
1375
1381
 
1376
1382
  def _inference_images_ids(
1377
- self, api: Api, state: dict, images_ids: List[int], async_inference_request_uuid: str = None
1383
+ self,
1384
+ api: Api,
1385
+ state: dict,
1386
+ images_ids: List[int],
1387
+ async_inference_request_uuid: str = None,
1378
1388
  ):
1379
1389
  """Inference images by ids.
1380
1390
  If "output_project_id" in state, upload images and annotations to the output project.
@@ -1799,7 +1809,8 @@ class Inference:
1799
1809
  dataset_id = _get_or_create_new_dataset(output_project_id, src_dataset_id)
1800
1810
  image_names = [result["image_name"] for result in results]
1801
1811
  image_infos = api.image.get_list(
1802
- dataset_id, filters=[{"field": "name", "operator": "in", "value": image_names}]
1812
+ dataset_id,
1813
+ filters=[{"field": "name", "operator": "in", "value": image_names}],
1803
1814
  )
1804
1815
  meta_changed = False
1805
1816
  anns = []
@@ -2104,7 +2115,10 @@ class Inference:
2104
2115
  # Read images
2105
2116
  if cache_project_on_model:
2106
2117
  images_nps = []
2107
- for dataset_id, images_infos in images_infos_batch_by_dataset.items():
2118
+ for (
2119
+ dataset_id,
2120
+ images_infos,
2121
+ ) in images_infos_batch_by_dataset.items():
2108
2122
  dataset_info = datasets_infos_dict[dataset_id]
2109
2123
  images_paths, _ = zip(
2110
2124
  *read_from_cached_project(
@@ -2116,7 +2130,10 @@ class Inference:
2116
2130
  images_nps.extend([sly_image.read(path) for path in images_paths])
2117
2131
  else:
2118
2132
  images_nps = []
2119
- for dataset_id, images_infos in images_infos_batch_by_dataset.items():
2133
+ for (
2134
+ dataset_id,
2135
+ images_infos,
2136
+ ) in images_infos_batch_by_dataset.items():
2120
2137
  images_nps.extend(
2121
2138
  self.cache.download_images(
2122
2139
  api,
@@ -2845,7 +2862,8 @@ def update_meta_and_ann(meta: ProjectMeta, ann: Annotation):
2845
2862
  """Update project meta and annotation to match each other
2846
2863
  If obj class or tag meta from annotation conflicts with project meta
2847
2864
  add suffix to obj class or tag meta.
2848
- Return tuple of updated project meta, annotation and boolean flag if meta was changed."""
2865
+ Return tuple of updated project meta, annotation and boolean flag if meta was changed.
2866
+ """
2849
2867
  obj_classes_suffixes = ["_nn"]
2850
2868
  tag_meta_suffixes = ["_nn"]
2851
2869
  ann_obj_classes = {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: supervisely
3
- Version: 6.73.260
3
+ Version: 6.73.261
4
4
  Summary: Supervisely Python SDK.
5
5
  Home-page: https://github.com/supervisely/supervisely
6
6
  Author: Supervisely
@@ -250,7 +250,7 @@ supervisely/app/widgets/empty/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
250
250
  supervisely/app/widgets/empty/empty.py,sha256=fCr8I7CQ2XLo59bl2txjDrblOGiu0TzUcM-Pq6s7gKY,1285
251
251
  supervisely/app/widgets/empty/template.html,sha256=aDBKkin5aLuqByzNN517-rTYCGIg5SPKgnysYMPYjv8,40
252
252
  supervisely/app/widgets/experiment_selector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
253
- supervisely/app/widgets/experiment_selector/experiment_selector.py,sha256=XZxhpD3utmHsHhKxo34-wJIfOaKXXznrFQVnVaHVWik,19456
253
+ supervisely/app/widgets/experiment_selector/experiment_selector.py,sha256=D1RrMuA6xXg8M5DyBUKro-AUqj3oFNMIlo6pZUR0SQY,19889
254
254
  supervisely/app/widgets/experiment_selector/style.css,sha256=-zPPXHnJvatYj_xVVAb7T8uoSsUTyhm5xCKWkkFQ78E,548
255
255
  supervisely/app/widgets/experiment_selector/template.html,sha256=k7f_Xl6nDUXXwu6IY_RblYni5TbZRRxCBduY5O_SyFs,2908
256
256
  supervisely/app/widgets/fast_table/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -386,7 +386,7 @@ supervisely/app/widgets/pagination/template.html,sha256=1z9pt2SOTjA5Kmt8YjSiyO8X
386
386
  supervisely/app/widgets/pie_chart/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
387
387
  supervisely/app/widgets/pie_chart/pie_chart.py,sha256=E0erw7kPXiudJzNhWMKdOnMgK9u6yYlPw10noKoO2jw,7809
388
388
  supervisely/app/widgets/pretrained_models_selector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
389
- supervisely/app/widgets/pretrained_models_selector/pretrained_models_selector.py,sha256=h6R5bFa1BNCqskFKV9yMGzhY4rf1ZT3ZBh8MKfG87Ko,12394
389
+ supervisely/app/widgets/pretrained_models_selector/pretrained_models_selector.py,sha256=y21fRcDWuP1RbqxNzy3MRxWFi8-f9pV0SsDaNIWqlvE,14102
390
390
  supervisely/app/widgets/pretrained_models_selector/style.css,sha256=po3FssuZhg3lKFU3VcTLqTW-qTCXLDnxYi2lCtYXhBc,363
391
391
  supervisely/app/widgets/pretrained_models_selector/template.html,sha256=4owO7X84Ii35vMioeTOwMAdR9OwlvLFe19MNPDX4kWM,5170
392
392
  supervisely/app/widgets/project_selector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -718,7 +718,7 @@ supervisely/nn/prediction_dto.py,sha256=8QQE6h_feOf3bjWtyG_PoU8FIQrr4g8PoMOyoscm
718
718
  supervisely/nn/task_type.py,sha256=UJvSJ4L3I08j_e6sU6Ptu7kS5p1H09rfhfoDUSZ2iys,522
719
719
  supervisely/nn/utils.py,sha256=-Xjv5KLu8CTtyi7acqsIX1E0dDwKZPED4D6b4Z_Ln3k,1451
720
720
  supervisely/nn/artifacts/__init__.py,sha256=m7KYTMzEJnoV9wcU_0xzgLuPz69Dqp9va0fP32tohV4,576
721
- supervisely/nn/artifacts/artifacts.py,sha256=SWVwaE40SPNElLp2NsRSOVh_ESRIXXZ1I-tMLEUYmTQ,20751
721
+ supervisely/nn/artifacts/artifacts.py,sha256=mizJzrzAMoURYnHU-Ap8OdUAxRngDtR5PC0RyDxBp8k,21079
722
722
  supervisely/nn/artifacts/detectron2.py,sha256=6iu5Yslc-SxCKJVNl6sn84qeXmD-JIQShJIxuLdzf2o,1673
723
723
  supervisely/nn/artifacts/hrda.py,sha256=3DzbjDIt9YuLozMrKmYYw13oxc14xju2vzbxKVq2G4I,1073
724
724
  supervisely/nn/artifacts/mmclassification.py,sha256=M0m9HHF5koHsl5RuFkRU0_clckA1sFty3X6awB2eKNo,1527
@@ -859,7 +859,7 @@ supervisely/nn/benchmark/visualization/widgets/table/__init__.py,sha256=47DEQpj8
859
859
  supervisely/nn/benchmark/visualization/widgets/table/table.py,sha256=atmDnF1Af6qLQBUjLhK18RMDKAYlxnsuVHMSEa5a-e8,4319
860
860
  supervisely/nn/inference/__init__.py,sha256=mtEci4Puu-fRXDnGn8RP47o97rv3VTE0hjbYO34Zwqg,1622
861
861
  supervisely/nn/inference/cache.py,sha256=KvzCgMbEBLdiJAxJDLicIPKAlYb52P9_kpNPWfiVY8Y,28194
862
- supervisely/nn/inference/inference.py,sha256=1QLeQmAmo29LoM9uFQjI5iDcuOyoltL4QR2Han9f2MM,128420
862
+ supervisely/nn/inference/inference.py,sha256=acNJH-1UthvJgyhI-9KJv8hzo8LjOVVdXPkoEuwfRLg,128864
863
863
  supervisely/nn/inference/session.py,sha256=jmkkxbe2kH-lEgUU6Afh62jP68dxfhF5v6OGDfLU62E,35757
864
864
  supervisely/nn/inference/video_inference.py,sha256=8Bshjr6rDyLay5Za8IB8Dr6FURMO2R_v7aELasO8pR4,5746
865
865
  supervisely/nn/inference/gui/__init__.py,sha256=wCxd-lF5Zhcwsis-wScDA8n1Gk_1O00PKgDviUZ3F1U,221
@@ -1057,9 +1057,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
1057
1057
  supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
1058
1058
  supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
1059
1059
  supervisely_lib/__init__.py,sha256=7-3QnN8Zf0wj8NCr2oJmqoQWMKKPKTECvjH9pd2S5vY,159
1060
- supervisely-6.73.260.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1061
- supervisely-6.73.260.dist-info/METADATA,sha256=CPwcqKvIAjMyeGM6DRLQKHF3owWEcixltIqVe4T0x-E,33573
1062
- supervisely-6.73.260.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
1063
- supervisely-6.73.260.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1064
- supervisely-6.73.260.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1065
- supervisely-6.73.260.dist-info/RECORD,,
1060
+ supervisely-6.73.261.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1061
+ supervisely-6.73.261.dist-info/METADATA,sha256=-ebDT49QDbB4Ly0fCqehbeu-_SN7bLV1lObohSxHS4M,33573
1062
+ supervisely-6.73.261.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
1063
+ supervisely-6.73.261.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1064
+ supervisely-6.73.261.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1065
+ supervisely-6.73.261.dist-info/RECORD,,