From 8a9785739297888788b87b424ab81a758e095b77 Mon Sep 17 00:00:00 2001 From: venkatram-dev Date: Thu, 19 Sep 2024 06:57:32 -0700 Subject: [PATCH 1/4] fix_assert_model_version --- roboflow/core/version.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/roboflow/core/version.py b/roboflow/core/version.py index 60fe4a4a..9e3ff44c 100644 --- a/roboflow/core/version.py +++ b/roboflow/core/version.py @@ -446,6 +446,37 @@ def live_plot(epochs, mAP, loss, title=""): time.sleep(5) + if not self.model: + if self.type == TYPE_OBJECT_DETECTION: + self.model = ObjectDetectionModel( + self.__api_key, + self.id, + self.name, + self.version, + colors=self.colors, + preprocessing=self.preprocessing, + ) + elif self.type == TYPE_CLASSICATION: + self.model = ClassificationModel( + self.__api_key, + self.id, + self.name, + self.version, + colors=self.colors, + preprocessing=self.preprocessing, + ) + elif self.type == TYPE_INSTANCE_SEGMENTATION: + self.model = InstanceSegmentationModel( + self.__api_key, + self.id, + colors=self.colors, + preprocessing=self.preprocessing, + ) + elif self.type == TYPE_SEMANTIC_SEGMENTATION: + self.model = SemanticSegmentationModel(self.__api_key, self.id) + elif self.type == TYPE_KEYPOINT_DETECTION: + self.model = KeypointDetectionModel(self.__api_key, self.id, version=self.version) + # return the model object assert self.model return self.model From a78dfea5481b7d14cd66cb38d3cab08a02cdc2d3 Mon Sep 17 00:00:00 2001 From: venkatram-dev Date: Wed, 2 Oct 2024 09:29:07 -0700 Subject: [PATCH 2/4] add defensive model not exist check --- roboflow/core/version.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/roboflow/core/version.py b/roboflow/core/version.py index 9e3ff44c..7e90ac62 100644 --- a/roboflow/core/version.py +++ b/roboflow/core/version.py @@ -446,7 +446,14 @@ def live_plot(epochs, mAP, loss, title=""): time.sleep(5) - if not self.model: + response = requests.get(f"{API_URL}/{workspace}/{project}/{self.version}?api_key={self.__api_key}") + if response.ok: + version_info = response.json()["version"] + has_model = bool(version_info.get("models")) + else: + has_model = False + + if not has_model: if self.type == TYPE_OBJECT_DETECTION: self.model = ObjectDetectionModel( self.__api_key, @@ -476,6 +483,9 @@ def live_plot(epochs, mAP, loss, title=""): self.model = SemanticSegmentationModel(self.__api_key, self.id) elif self.type == TYPE_KEYPOINT_DETECTION: self.model = KeypointDetectionModel(self.__api_key, self.id, version=self.version) + else: + # Raise an exception if the model type is unsupported or unknown + raise ValueError(f"Unsupported model type: {self.type}") # return the model object assert self.model From af4eb478f5f7508c2e6b62f93c49016b04ae190d Mon Sep 17 00:00:00 2001 From: venkatram-dev Date: Thu, 3 Oct 2024 07:37:00 -0700 Subject: [PATCH 3/4] remove comment for exception --- roboflow/core/version.py | 1 - 1 file changed, 1 deletion(-) diff --git a/roboflow/core/version.py b/roboflow/core/version.py index 7e90ac62..9437240f 100644 --- a/roboflow/core/version.py +++ b/roboflow/core/version.py @@ -484,7 +484,6 @@ def live_plot(epochs, mAP, loss, title=""): elif self.type == TYPE_KEYPOINT_DETECTION: self.model = KeypointDetectionModel(self.__api_key, self.id, version=self.version) else: - # Raise an exception if the model type is unsupported or unknown raise ValueError(f"Unsupported model type: {self.type}") # return the model object From b947bfc46e4c1307c0f996d97a60dbb1edbbc147 Mon Sep 17 00:00:00 2001 From: venkatram-dev Date: Thu, 3 Oct 2024 10:27:21 -0700 Subject: [PATCH 4/4] remove version model defensive check --- roboflow/core/version.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/roboflow/core/version.py b/roboflow/core/version.py index 9437240f..f2bd6ee0 100644 --- a/roboflow/core/version.py +++ b/roboflow/core/version.py @@ -446,14 +446,7 @@ def live_plot(epochs, mAP, loss, title=""): time.sleep(5) - response = requests.get(f"{API_URL}/{workspace}/{project}/{self.version}?api_key={self.__api_key}") - if response.ok: - version_info = response.json()["version"] - has_model = bool(version_info.get("models")) - else: - has_model = False - - if not has_model: + if not self.model: if self.type == TYPE_OBJECT_DETECTION: self.model = ObjectDetectionModel( self.__api_key,