From 7f7896608f08a52680b40f53e5125ba620529d92 Mon Sep 17 00:00:00 2001 From: Iuri de Silvio Date: Sat, 22 Jun 2024 10:04:26 +0200 Subject: [PATCH] Fix all obvious bugs found by mypy --- roboflow/core/project.py | 1 + roboflow/core/version.py | 8 ++++---- roboflow/core/workspace.py | 2 +- roboflow/models/video.py | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/roboflow/core/project.py b/roboflow/core/project.py index 79f01152..ccec7a7e 100644 --- a/roboflow/core/project.py +++ b/roboflow/core/project.py @@ -311,6 +311,7 @@ def version(self, version_number: int, local: str = None): local=None, workspace="", project="", + public=True, ) version_info = self.get_version_information() diff --git a/roboflow/core/version.py b/roboflow/core/version.py index e83a1352..f6ffa95f 100644 --- a/roboflow/core/version.py +++ b/roboflow/core/version.py @@ -452,7 +452,7 @@ def deploy(self, model_type: str, model_path: str, filename: str = "weights/best import ultralytics except ImportError: - raise ( + raise RuntimeError( "The ultralytics python package is required to deploy yolov8" " models. Please install it with `pip install ultralytics`" ) @@ -465,7 +465,7 @@ def deploy(self, model_type: str, model_path: str, filename: str = "weights/best import ultralytics except ImportError: - raise ( + raise RuntimeError( "The ultralytics python package is required to deploy yolov10" " models. Please install it with `pip install ultralytics`" ) @@ -474,7 +474,7 @@ def deploy(self, model_type: str, model_path: str, filename: str = "weights/best try: import torch except ImportError: - raise ( + raise RuntimeError( "The torch python package is required to deploy yolov5 models." " Please install it with `pip install torch`" ) @@ -619,7 +619,7 @@ def deploy_yolonas(self, model_type: str, model_path: str, filename: str = "weig try: import torch except ImportError: - raise ( + raise RuntimeError( "The torch python package is required to deploy yolonas models." " Please install it with `pip install torch`" ) diff --git a/roboflow/core/workspace.py b/roboflow/core/workspace.py index 1922f891..9fa00f90 100644 --- a/roboflow/core/workspace.py +++ b/roboflow/core/workspace.py @@ -135,7 +135,7 @@ def clip_compare(self, dir: str = "", image_ext: str = ".png", target_image: str # grab all images in a given directory with ext type for image in glob.glob(f"./{dir}/*{image_ext}"): # compare image - similarity = clip_encode(image, target_image) + similarity = clip_encode(image, target_image, CLIP_FEATURIZE_URL) # map image name to similarity score comparisons.append({image: similarity}) comparisons = sorted(comparisons, key=lambda item: -list(item.values())[0]) diff --git a/roboflow/models/video.py b/roboflow/models/video.py index ae99399a..7307ebee 100644 --- a/roboflow/models/video.py +++ b/roboflow/models/video.py @@ -86,7 +86,7 @@ def predict( >>> prediction = model.predict("video.mp4", fps=5, inference_type="object-detection") """ # noqa: E501 // docs - url = urljoin(API_URL, "/video_upload_signed_url/?api_key=", self.__api_key) + url = urljoin(API_URL, f"/video_upload_signed_url/?api_key={self.__api_key}") if fps > 30: raise Exception("FPS must be less than or equal to 30.") @@ -115,7 +115,7 @@ def predict( print("Uploaded video to signed url: " + signed_url) - url = urljoin(API_URL, "/videoinfer/?api_key=", self.__api_key) + url = urljoin(API_URL, f"/videoinfer/?api_key={self.__api_key}") models = [ { @@ -162,7 +162,7 @@ def poll_for_results(self, job_id: str = None) -> dict: if job_id is None: job_id = self.job_id - url = urljoin(API_URL, "/videoinfer/?api_key=", self.__api_key, "&job_id=", self.job_id) + url = urljoin(API_URL, f"/videoinfer/?api_key={self.__api_key}&job_id={self.job_id}") try: response = requests.get(url, headers={"Content-Type": "application/json"}) @@ -216,7 +216,7 @@ def poll_until_results(self, job_id) -> dict: attempts = 0 while True: - response = self.poll_for_response() + response = self.poll_for_results() attempts += 1