Skip to content

Instantly share code, notes, and snippets.

@TeraBytesMemory
Created March 27, 2021 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TeraBytesMemory/c74cebf56a3ee807aed40169c1c37569 to your computer and use it in GitHub Desktop.
Save TeraBytesMemory/c74cebf56a3ee807aed40169c1c37569 to your computer and use it in GitHub Desktop.
base64 image to numpy format
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