/AI-Intro

Course project of "AI Introduction" at PKU

Primary LanguagePython

AI Introduction - Term Project

Given a raw image, this program can find all the faces of the given raw image, and select one of them, then display the results of DLGAN.

Folders

  • ./raw : store the raw images which could be used as "test data set". Please feel free to add more images.

  • ./face : when you run 'find_faces.py' or 'Main.py', this folder would store all the faces of input images. Please read 'find_faces.py' for more detailed information.

  • ./camera : Our program supports capturing images from computer camera, this folder stores the images captured from camera.

  • ./DLGAN : store the results of DLGAN (12 images assigned different labels)

Files

  • ./Main.py : The main program. You can choose whether use camera or not by modifying the code.

  • ./find_faces.py : This file contains the function Find_faces_and_mark_them, which can find all the faces, and save them as file face/face0.png, face/face1.png. You can directly run this file

  • ./get_attributes.py : This file contains the function Attribute, which translates the attributes of the face (generated by Face++) into natural language.

  • ./graphic_interface.py : this file contains a class PhotoViewer, which can display the marked images, the top 4 biggest faces, and the DLGAN results.

  • ./camera.py : thie file used for calling the computer camera. If the user presses s in the keyboard, the images would be saved. Main.py would call this function.

  • ./client.py : Provides APIs (img_transform and img_interpolate functions) to the server which holds the DLGAN model.

    • The input of these APIs are path to the images (and of course some other arguments specifying how to modify them). See the docstrings in client.py for full details.
    • The return value is a dictionary with keys (hair, gender) in the transformation case, and (hair, gender, alpha) in the interpolation case, where alpha is the weight of img_appearance1.
    • Passing the argument save_result lets you save the generated images.
  • ./util.py : this file contains the necessary utilities which are used in ./client.py

  • ./facepp_API.py : This file contains the function 'connect_to_facepp', which can connect to 'Face++' website (a free CV paltform) and get the attributes (json format) of the given face, like age, gender. Please refer to Face++ for more details.

Usage

  1. If you just want to find all faces of the raw image, please run 'find_faces.py'

  2. If you want to display the results of DLGAN, please run 'Main.py'.

    • Before you run 'Main.py', please change the ssh port to go through the firewall

      • The command is in our WeChat Group

    • The server is currently running. If it is closed, you may login server and run the following commands:

          source /home/haodong/Workspace/env3/bin/activate
          cd /raid/zhaoyihao/code3/ILGAN/ILGAN-16/
          python server.py
      
      • The server account and password is in our WeChat Group

    • You should use this command pythonw Main.py (or python Main.py on Windows) to support graphic interface