Skip to content

Commit a78dfea

Browse files
committed
add defensive model not exist check
1 parent 8a97857 commit a78dfea

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

roboflow/core/version.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,14 @@ def live_plot(epochs, mAP, loss, title=""):
446446

447447
time.sleep(5)
448448

449-
if not self.model:
449+
response = requests.get(f"{API_URL}/{workspace}/{project}/{self.version}?api_key={self.__api_key}")
450+
if response.ok:
451+
version_info = response.json()["version"]
452+
has_model = bool(version_info.get("models"))
453+
else:
454+
has_model = False
455+
456+
if not has_model:
450457
if self.type == TYPE_OBJECT_DETECTION:
451458
self.model = ObjectDetectionModel(
452459
self.__api_key,
@@ -476,6 +483,9 @@ def live_plot(epochs, mAP, loss, title=""):
476483
self.model = SemanticSegmentationModel(self.__api_key, self.id)
477484
elif self.type == TYPE_KEYPOINT_DETECTION:
478485
self.model = KeypointDetectionModel(self.__api_key, self.id, version=self.version)
486+
else:
487+
# Raise an exception if the model type is unsupported or unknown
488+
raise ValueError(f"Unsupported model type: {self.type}")
479489

480490
# return the model object
481491
assert self.model

0 commit comments

Comments
 (0)