Created
June 3, 2020 17:29
-
-
Save zabir-nabil/2f72d9e909b084e88df10a76204cddb7 to your computer and use it in GitHub Desktop.
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
# A procedure which decodes base64 image, runs some machine learning model/ operation(s) (in our case we'll just return the mean of the pixel value) | |
import numpy as np | |
import base64 | |
import zlib | |
def predict(b64img_compressed, w, h): | |
b64decoded = base64.b64decode(b64img_compressed) | |
decompressed = b64decoded #zlib.decompress(b64decoded) | |
imgarr = np.frombuffer(decompressed, dtype=np.uint8).reshape(w, h, -1) | |
return imgarr.shape[2], np.mean(imgarr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment