- Convert image from base64 to any format
from utils.preprocessing.image import ImageConverter
img_data = '''
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABTmlDQ1BpY2MAAHjarY2/LwNhHIef14+g1SbiYrFcQsRQQkUwGKgQP4YSQ9vter2eJqfeXE/obDFKLB1M/AMsEhFqMBiYJGIQJv+AJiLR5jWUtBaTZ/k+efJJvtDQa0jpNAHrWc9dmZvWY/GE3vKCjyABWpkwzJycikaXAH7ub94fEAD3A4aUzut5sGBfzN4tXs5kL7o3C/yNL2XlTKAMWKZ0PRApoGfLkx6IXUBzY/EEiANAs6t+DGjJql8Dmru6EgHxCOjmmpEC8QGEknXdrvPvvwD+mUxOOkZej47w73jWtgcQ2ZB5N2OvefqUlI6lz2fNwZAeHhoehVg8oVfXpWUEILpua23nBSaLSqnzWlsowskY+M5qrX8cOvxwcyYN1wCgEWhIp+HtGAJR6DyFtnIuPRIGQLRPQ/OzUqU+aNmHyp5Sn4dKVY6g8Qmusl9H/2ebA6bD+AAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5AMECxIgxgyhSQAACzdJREFUeNrtWmlwldUZft5zvvUuyV1CEtZAAyQBFKjFUaRutSJYXBDb2rHUVgi1nXbGqXaZ6Z922rFOZzptB1ChrdNlrFXpIlhABCx0HY0IxYYlVEFFBQkkd/3u953z9kdIa0PuzYXkBmvzzHx/7nnvOe/znPO+Z5V4l6ClpQnpdBrRaLRWSrHANI1LXNfl+rq6Y67rcjqdOd8uVg7JZBKOYyMUcptd19lo21bOti3fcexXQiF36XXXzqf6+rrz7WZlEI/HYNsWQiG3xXHsnbZt8Ts/x7EPVVVFp0SjkYq0L84v+Tiy2SyklC1a67XMPK+vDTOP932/yff995YAiUQM2WwGQsjm0+Qv68+OiPJSym4hKuPqeREgmUwgk8lCStnMr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XRNQhhFhDQj7M2u8MRafDWbSyIn5WTIBeqB23QtRWU+rvRyYFvlrErOczYxqABMC9Z4QFgE4QUTsRbSIh1htO1SsceFy1ZENF/au4AL3wNizB0YO7kBw31VEqGA3merA+vSwUKRL0hjCMN19/5UC+cdocWAsfHS7XRjCCEYxgBCMYwQhG8H+JfwG9gi47C2yRAAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMC0wMy0wNFQxNTowMTo0MSswNjowMBNPzxUAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjAtMDMtMDRUMTU6MDE6MzcrMDY6MDALB0uKAAAAKHRFWHRpY2M6Y29weXJpZ2h0AENvcHlyaWdodCBBcHBsZSBJbmMuLCAyMDE1Uf15/AAAABp0RVh0aWNjOmRlc2NyaXB0aW9uAERpc3BsYXkgUDOPebu8AAAAG3RFWHRpY2M6bWFudWZhY3R1cmVyAERpc3BsYXkgUDMy4RxJAAAAFHRFWHRpY2M6bW9kZWwARGlzcGxheSBQM95n/9EAAAAASUVORK5CYII=
'''
image_convert = ImageConverter(image_name='nid_number.png', output_dir='/home/shakil/Tensorlow/object_detection/images/known_images')
img_path = image_convert.from_base64(image_data=img_data) # base64 image data get from Porichoy
- Crop face from this image
from utils.preprocessing.image import ImagePreprocessing
from face_detection.one_shot import FaceRecognition
ip = ImagePreprocessing(source='/home/shakil/Tensorlow/object_detection/images/known_images')
ip.face_crop(image=img_path)
fr = FaceRecognition(known_data_directory='/home/shakil/Tensorlow/object_detection/images/known_images')
fr.save()
# save into pickle file
- One shot face recognition
from face_detection.one_shot import FaceRecognition
upload_image = '' # image which has taken from frontend selfie
fr = FaceRecognition(known_data_directory='/home/shakil/Tensorlow/object_detection/images/known_images')
result = fr.nid_verification(upload_image, nid_no='022203322')
print(result['match'], result['accuracy']) # match return True or False, accuracy return accurate percent