Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API has convert("BGR") when loading a jpg image? #1023

Closed
AmrRahmy opened this issue Feb 16, 2024 · 4 comments
Closed

API has convert("BGR") when loading a jpg image? #1023

AmrRahmy opened this issue Feb 16, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@AmrRahmy
Copy link

AmrRahmy commented Feb 16, 2024

i am more familiar with java and c# but while debugging an error in the api endpoint,
/represent or http://localhost:5000/represent

it seems that if you supply a regular image, it errors out with,

{
    "error": "Exception while representing: conversion from RGB to BGR not supported"
}

looking into it, it seems the file 'preprocessing.py', function 'def load_image(img: Union[str, np.ndarray]) -> Tuple[np.ndarray, str]:'

if img.startswith("http"):
        return (
            np.array(Image.open(requests.get(img, stream=True, timeout=60).raw).convert("BGR")),
            # return url as image name
            img,
        )

instead of

if img.startswith("http"):
        return (
            np.array(Image.open(requests.get(img, stream=True, timeout=60).raw)),
            # return url as image name
            img,
        )

as if it's expecting an opencv compatible image or mat? even if the detector_backend is set to 'retinaface'

http request body tried,

{
    "model_name": "Facenet",
    "img": "http://192.168.3.90/sharedDirectory/face.jpg",
    "detector_backend": "retinaface",
    "distance_metric": "cosine"
}
{
    "img": "http://192.168.3.90/sharedDirectory/face.jpg"
}

url is valid and accessible.

@serengil serengil added the bug Something isn't working label Feb 16, 2024
@serengil
Copy link
Owner

Would you please share the image? Could it be gray scale?

@AmrRahmy
Copy link
Author

face
it's from celebrity faces dataset

@serengil
Copy link
Owner

Oh I see the root cause of the bug. Will fix this today.

@serengil
Copy link
Owner

Closed with PR - #1026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants