File size: 808 Bytes
f8254f4 0d71559 a1cee1f f8254f4 3ee182f a1cee1f f8254f4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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, 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 |