|
import sys |
|
from glob import glob |
|
from pathlib import Path |
|
import os |
|
import subprocess |
|
|
|
import pip |
|
from huggingface_hub import snapshot_download |
|
|
|
|
|
def install_packages(packages_path: Path): |
|
wheels = glob(str(packages_path / '*.whl')) |
|
for wheel in wheels: |
|
failed = pip.main(["install", wheel]) |
|
if failed: |
|
raise IOError(wheel) |
|
|
|
|
|
def get_seefood_classifier(): |
|
model_repo = 'ronig/seefood' |
|
local_repo_path = Path(snapshot_download(model_repo, use_auth_token=os.environ['TOKEN'])) |
|
subprocess.run(["pip", "install", "-r", str(local_repo_path / 'requirements.txt')]) |
|
install_packages(local_repo_path / 'build' / 'dist') |
|
sys.path.append(str(local_repo_path)) |
|
from seefood_classifier import SeefoodClassifier |
|
classifier = SeefoodClassifier() |
|
return classifier |