File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
from tensorflow_hub import resolver
6
6
7
- url_pattern = re .compile (r"https?://([a-z]+\.)?kaggle.com/models/(?P<owner>[^\\/]+)/(?P<model>[^\\/]+)/(?P<framework>[^\\/]+)/(?P<variation>[^\\/]+)/(?P<version>[0-9]+)$" )
7
+ short_url_pattern = re .compile (r"https?://([a-z]+\.)?kaggle.com/models/(?P<owner>[^\\/]+)/(?P<model>[^\\/]+)/(?P<framework>[^\\/]+)/(?P<variation>[^\\/]+)/(?P<version>[0-9]+)$" )
8
+ long_url_pattern = re .compile (r"https?://([a-z]+\.)?kaggle.com/models/(?P<owner>[^\\/]+)/(?P<model>[^\\/]+)/frameworks/(?P<framework>[^\\/]+)/variations/(?P<variation>[^\\/]+)/versions/(?P<version>[0-9]+)$" )
8
9
9
10
def _is_on_kaggle_notebook ():
10
11
return os .getenv ("KAGGLE_KERNEL_RUN_TYPE" ) != None and os .getenv ("KAGGLE_USER_SECRETS_TOKEN" ) != None
@@ -17,5 +18,5 @@ def is_supported(self, handle):
17
18
return _is_on_kaggle_notebook () and _is_kaggle_handle (handle )
18
19
19
20
def __call__ (self , handle ):
20
- m = url_pattern .match (handle )
21
+ m = long_url_pattern . match ( handle ) or short_url_pattern .match (handle )
21
22
return kagglehub .model_download (f"{ m .group ('owner' )} /{ m .group ('model' )} /{ m .group ('framework' ).lower ()} /{ m .group ('variation' )} /{ m .group ('version' )} " )
You can’t perform that action at this time.
0 commit comments