Skip to content

Commit

Permalink
Merge pull request #1154 from dlaflotte/main
Browse files Browse the repository at this point in the history
Allow use of prior cached model
  • Loading branch information
Erol444 authored Feb 15, 2024
2 parents 3c008f3 + 46c7226 commit 03ba356
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions depthai_sdk/src/depthai_sdk/integrations/roboflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ def _file_with_ext(self, folder: Path, ext: str) -> Optional[Path]:

def device_update(self, device: dai.Device) -> Path:
mxid = device.getMxId()
url = f"https://api.roboflow.com/depthai/{self.config['model']}/?api_key={self.config['key']}&device={mxid}"
response = requests.get(url)

name = self.config['model'].replace('/', '_') # '/' isn't valid folder name

model_folder = ROBOFLOW_MODELS / name
json_file = self._file_with_ext(model_folder, '.json')
if json_file:
return json_file

#Check the URL after checking the cache to make sure vision systems that are offline don't throw an exception
url = f"https://api.roboflow.com/depthai/{self.config['model']}/?api_key={self.config['key']}&device={mxid}"
response = requests.get(url)


json_res = response.json()
if "error" in json_res:
raise Exception(json_res['error'])
Expand Down

0 comments on commit 03ba356

Please sign in to comment.