def write_image_to_dir(data, dd): image_base64 = data["image_base64"] _, image_base64 = image_base64.split(",") image_data = base64.b64decode(image_base64) if "image_label" in data.keys(): image_label = data["image_label"] else: image_label = "label" image_id = gen_uuid() image_name = gen_image_name(image_label, image_id) dd.set(image_name, image_data) return image_id
def create_user(self, params): user_id = gen_uuid() dir_user = Dir(path="../dir_user/"+user_id) dir_sample_shape = Dir(path=dir_user.path_join("sample_shape"), mode="binary") dir_std_shape = Dir(path=dir_user.path_join("std_shape"), mode="binary") dir_predict_shape = Dir(path=dir_user.path_join("predict_shape"), mode="binary") USER_DICT[user_id] = { "dir_user": dir_user, "dir_sample_shape": dir_sample_shape, "dir_std_shape": dir_std_shape, "dir_predict_shape": dir_predict_shape, } return dict(user_id=user_id)