Created
March 27, 2021 02:06
-
-
Save TeraBytesMemory/c74cebf56a3ee807aed40169c1c37569 to your computer and use it in GitHub Desktop.
base64 image to numpy format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def base64_decoder(img_base64: str) -> np.ndarray: | |
img_base64 = img_base64.split('base64,')[-1] | |
img_data = base64.b64decode(img_base64) | |
img_np = np.fromstring(img_data, np.uint8) | |
img = cv2.imdecode(img_np, cv2.IMREAD_COLOR) | |
return img |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment