exadel-inc / CompreFace

Leading free and open-source face recognition system
https://exadel.com/accelerator-showcase/compreface/
Apache License 2.0
5.7k stars 775 forks source link

Uploading Multiple Subjects #1096

Closed hamzaziizzz closed 1 year ago

hamzaziizzz commented 1 year ago

Hello, I would like to inquire about the process of uploading subjects in CompreFace all at once. In my DATASET folder, there are 97 subjects or individuals, each consisting of 5 images. I would like to upload all the subjects simultaneously, as manually creating 97 subjects is quite cumbersome.

I came across the following script:

curl -X POST "http://localhost:8000/api/v1/recognition/faces?subject=<subject>&det_prob_threshold=<det_prob_threshold>" \
-H "Content-Type: multipart/form-data" \
-H "x-api-key: <service_api_key>" \
-F file=@<local_file> 

However, I believe this script is designed for a single subject only.

hamzaziizzz commented 1 year ago

I figured the solution for this. I wrote a bash script where I put the curl POST command into a loop and it works perfectly fine. Here is the bash script that I used.

#!/bin/bash

# Specify the directory where the images are located
directory="/home/hamza/Pictures/Dataset_FR_22_06_2023_ABES_GLB"

# Loop through all subdirectories
for subdirectory in "$directory"/*; do
    # Loop through all images in the subdirectory
    for image in "$subdirectory"/*; do
        # Upload the image to the server
        curl -X POST "http://localhost:8080/api/v1/recognition/faces?subject=${subdirectory:52}&det_prob_threshold=0.8" \
        -H "Content-Type: multipart/form-data" \
        -H "x-api-key: 24d82699-f8a4-4c2f-aebe-14d34c05e9c4" \
        -F file=@$image
        # echo ${subdirectory:52}
    done
done