you can download the pre-trained model from here.
put zhu_geliang.pth
to the checkpoints folder.
After that you can run the following command to generate Zhu-Geliang face:
python .\generate.py -cp ./checkpoint/zhu_geliang.pth -bs 1 --interval 10 --show -sp "result/zhugeliang.png" --sampler "ddim" --steps 200
These are the parameters of generate.py
:
-cp
: the path of checkpoint.--device
: the device used. 'cuda' (default) or 'cpu'.--sampler
: the sampler method, can be 'ddpm'(default) or 'ddim'.-bs
: how many images to generate at once. Default 16.--result_only
: whether to output only the generated results. Default False.--interval
: extract an image every how many steps. Only valid without the result_only parameter. Default 50.--eta
: ddim parameter, in the paper. Default 0.0.--steps
: ddim sampling steps. Default 100.--method
: ddim sampling method. can be 'linear'(default) or 'quadratic'.--nrow
: how many images are displayed in a row. Only valid with the result_only parameter. Default 4.--show
: whether to display the result image. Default False.-sp
: save path of the result image. Default None.--to_grayscale
: convert images to grayscale. Default False.
This check point will generate 64x64 image, If you want to generate custom size images, you can train the model with different image_size
parameter in config.yml file.
I use yolov5-crowdhuman to make the Zhu-Geliang datasets, and I use the opencv cv2.face.LBPHFaceRecognizer
to find the face of Zhu-Geliang.
If you want to see the code, please go to the branch ZhuGeliangRecognizer, and you can find the code in the following files:
FaceDetectionAndCrop.py
and
Find_Zhu_Geliang.py
I upload the datasets to the Kaggle, you can download it from here derectly.
put this all datasets to zhugeliang_face folder
python Create_Square_Datasets.py --size 64 --num-threads 16
These are the parameters of Create_Square_Datasets.py
:
--datasets-path
: the path of the datasets. default isdata/zhugeliang_face
--output-path
: the path of the output datasets. default isdata/zhugeliang_face_square
--size
: the size of the output image. default is 64, if you want to train another size image, you can change it.--num-threads
: the number of threads. default is 16, if you have more than 16 cores, you can change it.
Almost all the parameters that can be modified are listed in the config.yml file. You can modify the relevant parameters as needed, and then run the train.py file to start training.
python train.py
My Training Loss