Skip to content

Commit

Permalink
add: a test added for 'represent' API endpoint to check the url input
Browse files Browse the repository at this point in the history
    This commit adds a new test case for the 'represent' API endpoint. The test verifies that the endpoint correctly processes an image URL and returns the expected data structure, including the correct number of face embeddings, face confidence, and facial area for each detected face in the image.
  • Loading branch information
rezakarbasi committed Mar 20, 2024
1 parent 5d49679 commit 593a3c2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,29 @@ def test_represent_encoded(self):

logger.info("✅ representation api test is done")

def test_represent_url(self):
data = {
"model_name": "Facenet",
"detector_backend": "mtcnn",
"img": "https://github.com/serengil/deepface/blob/master/tests/dataset/couple.jpg?raw=true"
}

response = self.app.post("/represent", json=data)
assert response.status_code == 200
result = response.json
logger.debug(result)
assert result.get("results") is not None
assert isinstance(result["results"], list) is True
assert len(result["results"]) == 2 # 2 faces are in the image link
for i in result["results"]:
assert i.get("embedding") is not None
assert isinstance(i.get("embedding"), list) is True
assert len(i.get("embedding")) == 128
assert i.get("face_confidence") is not None
assert i.get("facial_area") is not None

logger.info("✅ representation api test is done")

def test_analyze(self):
data = {
"img": "dataset/img1.jpg",
Expand Down

0 comments on commit 593a3c2

Please sign in to comment.