HighonPi / ArcFace

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ArcFace

ai_ml Project


Hey! These are our codes and presentations for the ai_ml Deep Learning project. We have made Arcface, which is the SOTA (State of the Art) face recognition model.
Link to paper.
Links to all videos are present at the end of this document. It is recommended to watch the videos before trying out the code.



Instructions to run Training Code


  1. Create a python3 virtual environment in python3 or conda and download all the necessary libraries to make the project codes run. All required libraries are listed in the requirements.txt.
@ai_ml_warrior: conda create --name arcface
@ai_ml_warrior: conda activate arcface
(arcface)@ai_ml_warrior: pip install -r requirements.txt
    • The main training code in the Codes section of this folder is the python3 file named arcface_training_code_v2.py.
    • The datasets for training are present in the folder named datasets inside Codes folder.
@ai_ml_warrior: cd Codes
  1. Activate the newly created venv with all neccessary libraries.
@ai_ml_warrior: conda activate arcface
(arcface)@ai_ml_warrior: _
  • Run the arcface_training_code_v2.py file to start training.
(arcface)@ai_ml_warrior: python3 arcface_training_code_v2.py
  • Else if you are comfortable with ipynb notebooks open the Arcface_Training_Code_v2.ipynb notebook, change the kernel to the created venv and execute the cells in order to start training.
  1. Once the training reaches 50 epochs the model is saved in the Codes folder itself.


Instructions to run Vizualisations and Plots Code


  1. Activate the newly created venv with all neccessary libraries.
@ai_ml_warrior: conda activate arcface
(arcface)@ai_ml_warrior: _
  • Run the arcface_visualizations.py file to calculate threshold and create the plots.
(arcface)@ai_ml_warrior: python3 arcface_visualizations.py
  • Else if you are comfortable with ipynb notebooks open the Arcface_Visualizations.ipynb notebook, change the kernel to the created venv and execute the cells in order to calculate threshold and create the plots.

A) Executing ipynb notebook is preferred in this case.



Instructions to run Face Verification Code


  1. Activate the newly created venv with all neccessary libraries.
@ai_ml_warrior: conda activate arcface
(arcface)@ai_ml_warrior: _
    • Images are stored in the images folder.
    • Upload images you wish to verify. (make sure they are closely cropped images of faces.
    • Change path in line 152,153 in arcface_face_verification.py or the 5th cell in Arcface_Face_Verification.ipynb for face verification with paths to different images if you wish to.
  • Run the arcface_face_verification.py file to verify.
(arcface)@ai_ml_warrior: python3 arcface_face_verification.py
  • Else if you are comfortable with ipynb notebooks open the Arcface_Face_Verification.ipynb notebook, change the kernel to the created venv and execute the cells in order to load model then verify if both are the same people or not.

A) Executing ipynb notebook is preferred in this case.
B) In this file, a Resnet-34 model is used as a backbone. We trained it to reduce model size for our flask deployment, but it wasn't significantly smaller than our Resnet-50 backbone arcface model.



Instructions to run Face Verification Deployment with Gradio


  1. Activate the newly created venv with all neccessary libraries.
@ai_ml_warrior: conda activate arcface
(arcface)@ai_ml_warrior: _
  1. Run the gradio_dep.py file to start the server.
(arcface)@ai_ml_warrior: python3 gradio_dep.py
ArcFace expects  []  inputs
and it represents faces as  (512,)  dimensional vectors
Running on local URL:  http://127.0.0.1:7860
Running on public URL: https://90d977e0e66***20.gradio.app
  1. Copy the address in which the server is running and open it on your default browser.
    • Once you select image 1 and image 2, don't forget to upload them before trying to verify if they are the same people.


Other Links




Project by

      200050084 Karthikeya
      200050101 Poorna Teja
      200050103 Balasubramanian
      200050134 Shubh Kumar

About


Languages

Language:Jupyter Notebook 96.4%Language:Python 3.6%