Instruction: Build a Man vs Woman image classifier.
- Install TensorFlow and Keras
Follow the below guideline to install TensorFlow and Keras onto your computer
- Preparing the data files.
Download the two data files, man500.zip and woman500.zip from Moodle. Unzip (decompress) them.
- On your computer, prepare one folder for training and one folder for testing. Inside each folder, add one folder for man and one folder for woman. For example
- From the photos that you downloaded from Moodle, select about200 men images and copy them into the training\man folder. The images you select should be diverse (i.e., it should contain male images of different types). Repeat this step for the woman images.
- Go online, and look for at least20 male images of your choice, and place them into the testing\man folder. The images you select should be diverse. Repeat this step for woman images.
- Complete and run the training programs
Download the program train_stu.py from Moodle. Place it in the same directory as your testing and training images folders. Study it.
Open it and update the name of your folder. (e.g. “training”).
Change the output Model name to s<your student id>_model.h5
(e.g, s190001.h1 if your student id is s190001)
Study the setting of the program, then start running it. It may take a while on slower computers without GPUs (such as our lab’s computers)
- At the end, note down the final accuracy (e.g., 95.206 (%))
Option 1: Manual evaluation
Download the program predict_stu.py. Open it and modify the model name to the one that you have trained.
Where sXXXXXX should be your student ID.
Place this program together with your testing images (i.e. at the same folder). Test your model by entering the corresponding file names.
Do you have a good enough model? If yes, congratulation!
If not, do the following:
- Check your program first, to make sure there is no mistake, especially the folder names.
- You may try to adjust the training images by using more representative photos
- You may do more rounds of training by adjusting the training parameters (e.g. the epochs)
Option 2: Automatic evaluation
Alternatively, if you prefer to do the evaluation automatically, you may use the program testing_stu_all.py, which is also on Moodle. Place your man and woman testing images in two separate folders, and modify the path in the program accordingly. Also, do not forget to modify your model name
Try to get an accuracy of over 80% in your evaluation.
本网站支持 Alipay WeChatPay PayPal等支付方式
E-mail: firstname.lastname@example.org 微信号:vipnxx