From a1a89ea65f3b43a1eb2ea7f2552682aee9c2a403 Mon Sep 17 00:00:00 2001 From: Brandon Amos Date: Tue, 8 Dec 2015 16:41:40 -0500 Subject: [PATCH] Remove skimage dependency for #50. --- demos/web/create-unknown-vectors.py | 2 -- openface/alignment/naive_dlib.py | 2 -- openface/data.py | 26 ++++++++++++++------------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/demos/web/create-unknown-vectors.py b/demos/web/create-unknown-vectors.py index 9c90f7e..6e844d2 100755 --- a/demos/web/create-unknown-vectors.py +++ b/demos/web/create-unknown-vectors.py @@ -25,8 +25,6 @@ import random import cv2 -from skimage import io - import openface from openface.alignment import NaiveDlib from openface.data import iterImgs diff --git a/openface/alignment/naive_dlib.py b/openface/alignment/naive_dlib.py index 769c092..f3d8a4d 100644 --- a/openface/alignment/naive_dlib.py +++ b/openface/alignment/naive_dlib.py @@ -20,8 +20,6 @@ import os import random import sys -from skimage import io - from .. import helper from .. import data diff --git a/openface/data.py b/openface/data.py index 9c984aa..82f4400 100644 --- a/openface/data.py +++ b/openface/data.py @@ -14,8 +14,7 @@ import os -from skimage import io - +import cv2 class Image: @@ -25,17 +24,20 @@ class Image: self.path = path self.rgb = None - def getRGB(self, cache=False): - if self.rgb is not None: - return self.rgb + def getBGR(self): + try: + bgr = cv2.imread(self.path) + except: + bgr = None + return bgr + + def getRGB(self): + bgr = self.getBGR() + if bgr is not None: + rgb = cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB) else: - try: - rgb = io.imread(self.path) - except: - rgb = None - if cache: - self.rgb = rgb - return rgb + rgb = None + return rgb def __repr__(self): return "({}, {})".format(self.cls, self.name)