Create seefood_classifier_import.py
Browse files- seefood_classifier_import.py +24 -0
seefood_classifier_import.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from glob import glob
|
3 |
+
from pathlib import Path
|
4 |
+
|
5 |
+
import pip
|
6 |
+
from huggingface_hub import snapshot_download
|
7 |
+
|
8 |
+
|
9 |
+
def install_packages(packages_path: Path):
|
10 |
+
wheels = glob(str(packages_path / '*.whl'))
|
11 |
+
for wheel in wheels:
|
12 |
+
failed = pip.main(["install", wheel])
|
13 |
+
if failed:
|
14 |
+
raise IOError(wheel)
|
15 |
+
|
16 |
+
|
17 |
+
def get_seefood_classifier():
|
18 |
+
model_repo = 'ronig/seefood'
|
19 |
+
local_repo_path = Path(snapshot_download(model_repo, cache_dir='./cache'))
|
20 |
+
install_packages(local_repo_path / 'build' / 'dist')
|
21 |
+
sys.path.append(str(local_repo_path))
|
22 |
+
from seefood_classifier import SeefoodClassifier
|
23 |
+
classifier = SeefoodClassifier()
|
24 |
+
return classifier
|