Skip to content

Commit 63fbf5e

Browse files
committed
load model from url
1 parent 700b4f2 commit 63fbf5e

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

roboflow/__init__.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import time
55

66
import requests
7+
from urllib.parse import urlparse
78

89
from roboflow.config import API_URL, APP_URL, DEMO_KEYS, load_roboflow_api_key
910
from roboflow.core.project import Project
@@ -12,7 +13,6 @@
1213

1314
__version__ = "0.2.292"
1415

15-
1616
def check_key(api_key, model, notebook, num_retries=0):
1717
if type(api_key) is not str:
1818
raise RuntimeError(
@@ -159,23 +159,22 @@ def train():
159159
print("training from " + operate_workspace.name)
160160

161161

162-
def load_model(project=None, version=None, local=None):
162+
def load_model(model_url):
163163
operate_workspace = initialize_roboflow()
164+
165+
if "universe.roboflow.com" in model_url or "app.roboflow.com" in model_url:
166+
parsed_url = urlparse(model_url)
167+
path_parts = parsed_url.path.split("/")
168+
project = path_parts[2]
169+
version = int(path_parts[-1])
170+
else:
171+
raise("Model URL must be from either app.roboflow.com or universe.roboflow.com")
172+
164173
project = operate_workspace.project(project)
165174
version = project.version(version)
166175
model = version.model
167176
return model
168177

169-
170-
# def set_project()
171-
172-
# def set_version()
173-
174-
# download()
175-
176-
# deploy()
177-
178-
179178
# continue distributing this object for back compatibility
180179
class Roboflow:
181180
def __init__(

0 commit comments

Comments
 (0)