mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 20:15:21 +00:00
Merge pull request #392 from KananMahammadli/master
Modified functions.py so that it can read from https
This commit is contained in:
commit
5cfc94e5bf
@ -4,6 +4,8 @@ import pandas as pd
|
|||||||
import cv2
|
import cv2
|
||||||
import base64
|
import base64
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from PIL import Image
|
||||||
|
import requests
|
||||||
|
|
||||||
from deepface.detectors import FaceDetector
|
from deepface.detectors import FaceDetector
|
||||||
|
|
||||||
@ -64,7 +66,6 @@ def loadBase64Img(uri):
|
|||||||
return img
|
return img
|
||||||
|
|
||||||
def load_image(img):
|
def load_image(img):
|
||||||
|
|
||||||
exact_image = False
|
exact_image = False
|
||||||
if type(img).__module__ == np.__name__:
|
if type(img).__module__ == np.__name__:
|
||||||
exact_image = True
|
exact_image = True
|
||||||
@ -73,11 +74,18 @@ def load_image(img):
|
|||||||
if len(img) > 11 and img[0:11] == "data:image/":
|
if len(img) > 11 and img[0:11] == "data:image/":
|
||||||
base64_img = True
|
base64_img = True
|
||||||
|
|
||||||
|
url_img = False
|
||||||
|
if len(img) > 11 and img.startswith("http"):
|
||||||
|
url_img = True
|
||||||
|
|
||||||
#---------------------------
|
#---------------------------
|
||||||
|
|
||||||
if base64_img == True:
|
if base64_img == True:
|
||||||
img = loadBase64Img(img)
|
img = loadBase64Img(img)
|
||||||
|
|
||||||
|
elif url_img:
|
||||||
|
img = np.array(Image.open(requests.get(img, stream=True).raw))
|
||||||
|
|
||||||
elif exact_image != True: #image path passed as input
|
elif exact_image != True: #image path passed as input
|
||||||
if os.path.isfile(img) != True:
|
if os.path.isfile(img) != True:
|
||||||
raise ValueError("Confirm that ",img," exists")
|
raise ValueError("Confirm that ",img," exists")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user