Example #1
0
import sys
from flask import Flask
from flask import jsonify
from flask import request
import jwt
from functools import wraps
from flasgger import Swagger
from flasgger import swag_from
from google.cloud.logging.handlers import ContainerEngineHandler
import logging
from lib import prediction, secrets

formatter = logging.Formatter("%(message)s")
handler = ContainerEngineHandler(stream=sys.stderr)
handler.setFormatter(formatter)
handler.setLevel(logging.INFO)
root = logging.getLogger()
root.addHandler(handler)
root.setLevel(logging.INFO)

app = Flask(__name__)
app.config["JSON_SORT_KEYS"] = False
app.config["SWAGGER"] = {
    "specs": [{
        "endpoint": "apispec_1",
        "route": "/api/apispec_1.json",
        "rule_filter": lambda rule: True,  # all in
        "model_filter": lambda tag: True,  # all in
    }],
    "static_url_path":
    "/api/flasgger_static",
import argparse
import logging
import sys
import os
import pandas as pd
import tensorflow as tf
from google.cloud.logging.handlers import ContainerEngineHandler
from sklearn.model_selection import GroupKFold
from tensorflow import keras
from tensorflow.python.lib.io import file_io
from typing import List

formatter = logging.Formatter("%(message)s")
handler = ContainerEngineHandler(stream=sys.stderr)
handler.setFormatter(formatter)
handler.setLevel("INFO")
log = logging.getLogger()
log.addHandler(handler)
log.setLevel("INFO")

MODEL = "efficientnetb4"
TARGET = ["fvc_last_3", "fvc_last_2", "fvc_last_1"]
CONF = {
    "efficientnetb0": {
        "resolution": 224,
        "output_size": 1280
    },
    "efficientnetb1": {
        "resolution": 240,
        "output_size": 0
    },