Skip to content

load_image is not same from url or from file #532

Closed
@mistake0316

Description

# in colab
from deepface.commons import functions
import numpy as np
url = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/45/MontreGousset001.jpg/440px-MontreGousset001.jpg"
file = "440px-MontreGousset001.jpg"
!wget {url} -O {file} -q

img_from_url = functions.load_image(url)
img_from_file = functions.load_image(file)

print(np.abs(img_from_url-img_from_file).mean())
# 98.4184350027692

elif url_img:
img = np.array(Image.open(requests.get(img, stream=True).raw).convert('RGB'))
elif exact_image != True: #image path passed as input
if os.path.isfile(img) != True:
raise ValueError("Confirm that ",img," exists")
img = cv2.imread(img)

The reason is because you convert the image to RBG with url
And for file, you use cv2.imread, the default setting is rgb

Please align those two methods

Metadata

Assignees

No one assigned

    Labels

    dependenciesPull requests that update a dependency file

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions