Spaces:
Build error
Build error
import cv2 | |
import numpy as np | |
import openface | |
import docker | |
class OpenFaceModel: | |
def __init__(self) -> None: | |
self.client = docker.from_env() | |
self.client.images.pull("bamos/openface") | |
def preprocess(self, image: bytes) -> np.ndarray: | |
raise NotImplemented | |
def embed(self, aligned_face): | |
container = self.client.containers.run( | |
"bamos/openface", | |
"python /root/openface/demos/classifier.py infer /root/openface/models/openface/celeb-classifier.nn4.small2.v1.pkl -", | |
detach=True, | |
stdin_open=True, | |
tty=True, | |
) | |
raise NotImplemented | |
return rep | |
def similarity(self, rep1, rep2): | |
return np.linalg.norm(rep1 - rep2, ord=2) | |