# coding: utf-8 import os import sys import re import base64 import json from io import BytesIO from function.modules import json_parser from function.modules import Client from keras.preprocessing import image from PIL import Image import numpy as np client = Client('fackAPI', silent=True) run = client.run train = client.train predict = client.predict work_path = 'function/' default_path =work_path # default_path ='' def handle(conf): def base64_to_image(base64_str, grayscale, target_size): base64_data = re.sub('^data:image/.+;base64,', '', base64_str) byte_data = base64.b64decode(base64_data) image_data = BytesIO(byte_data) img = image.load_img(image_data, grayscale, target_size) return image.img_to_array(img)
# You can use other public modules via our Client object with module's identifier # and parameters. # For more detailes, please see our online document - https://momodel.github.io/mo/# import os import sys # Import necessary packages from function.modules import json_parser from function.modules import Client # Initialise Client object client = Client(api_key='5asdfoasd0fnd0983', project_id='5af2abafe13823a5f1687062', user_ID='zhaofengli', project_type='app', source_file_path='3_Develop_and_Deploy_your_first_App.ipynb', silent=True) # Make run/train/predict commnad alias for furthur use run = client.run train = client.train predict = client.predict # Run a importred module # e.g. # conf = json_parser('{"rgb_image":null,"gray_image":null}') # result = run('zhaofengli/new_gender_classifier/0.0.2', conf) # # 'conf' is the parameters in dict form for the imported module # '[user_id]/[imported_module_name]/[version]' is the identifier of the imported module