Skip to content

Commit

Permalink
Attempt to fix issue with importlib for different Python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
prouast committed May 21, 2024
1 parent a0c7d8d commit 5a337a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vitallens/ssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import importlib.resources
import itertools
import logging
import numpy as np
import os
from prpy.numpy.signal import interpolate_vals
import sys
from typing import Tuple

if sys.version_info >= (3.9):
from importlib.resources import files
else:
from importlib_resources import files

from vitallens.utils import parse_video_inputs

INPUT_SIZE = (240, 320)
Expand Down Expand Up @@ -202,7 +207,7 @@ def __init__(
iou_threshold: Face detection iou threshold.
"""
import onnxruntime as rt
with importlib.resources.files('vitallens.models.Ultra-Light-Fast-Generic-Face-Detector-1MB') as model_dir:
with files('vitallens.models.Ultra-Light-Fast-Generic-Face-Detector-1MB') as model_dir:
self.model = rt.InferenceSession(os.path.join(model_dir, "model_rfb_320.onnx"), providers=['CPUExecutionProvider'])
self.iou_threshold = iou_threshold if iou_threshold is not None else self.config['threshold']
self.score_threshold = score_threshold
Expand Down

0 comments on commit 5a337a7

Please sign in to comment.