diff --git a/app_spec.yml b/app_spec.yml index 3635ae6..6785934 100644 --- a/app_spec.yml +++ b/app_spec.yml @@ -6,5 +6,5 @@ output: Output: name: Output - value_type: img + value_type: str description: '' diff --git a/handler.py b/handler.py index 6639374..c0a908b 100644 --- a/handler.py +++ b/handler.py @@ -10,11 +10,21 @@ model_PATH='/home/jovyan/work/src/output/models/model2000.ckpt' +import time +def run_time(func): + def inner(model, image, question): + back = func(model, image, question) + print("Runned time: {} s".format(round((time.time() - t)/10, 3))) + return back + t = time.time() + return inner + def load_demo_image(in_PATH): img = np.array(Image.open(in_PATH).convert('RGB'))[np.newaxis] / 255.0 img_p = util.preprocess_images_outpainting(img) return img_p +@run_time def inference(model_PATH, img_p): G_Z = tf.placeholder(tf.float32, shape=[None, IMAGE_SZ, IMAGE_SZ, 4], name='G_Z') G_sample = model.generator(G_Z) @@ -39,7 +49,7 @@ """ base64_str = conf['Photo'] image = load_demo_image(base64_str, image_size, device) - res = inference(model, image) + res = inference(model_PATH, image) # add your code return {'Output': res} diff --git a/src/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/src/.ipynb_checkpoints/Untitled-checkpoint.ipynb index 38b9a9c..b90f667 100644 --- a/src/.ipynb_checkpoints/Untitled-checkpoint.ipynb +++ b/src/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "769c9afd", + "id": "04c7f16a", "metadata": {}, "outputs": [ { @@ -40,7 +40,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "227c58c5", + "id": "0dd13c75", "metadata": {}, "outputs": [], "source": [ @@ -50,7 +50,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "dc65195f", + "id": "649a883e", "metadata": {}, "outputs": [], "source": [ @@ -67,7 +67,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "bcbe551f", + "id": "fba4c6ff", "metadata": {}, "outputs": [], "source": [ @@ -80,7 +80,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "36fcb0d9", + "id": "ff900f2b", "metadata": {}, "outputs": [], "source": [ @@ -101,8 +101,8 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "b79deb86", + "execution_count": 10, + "id": "9d164058", "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ " \"\"\"\n", " base64_str = conf['Photo']\n", " image = load_demo_image(base64_str, image_size, device)\n", - " res = inference(model, image)\n", + " res = inference(model_PATH, image)\n", " # add your code\n", " return {'Output': res}\n", " " diff --git a/src/Untitled.ipynb b/src/Untitled.ipynb index 972576c..d8f03c5 100644 --- a/src/Untitled.ipynb +++ b/src/Untitled.ipynb @@ -3,7 +3,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "3c86ef8a", + "id": "755152e5", "metadata": {}, "outputs": [ { @@ -40,7 +40,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "87b58a5a", + "id": "c45b2ba8", "metadata": {}, "outputs": [], "source": [ @@ -50,7 +50,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "4e963aed", + "id": "7eb0351a", "metadata": {}, "outputs": [], "source": [ @@ -67,7 +67,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "aba8e440", + "id": "196069cc", "metadata": {}, "outputs": [], "source": [ @@ -80,7 +80,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "bc8c0bf4", + "id": "e0a075d4", "metadata": {}, "outputs": [], "source": [ @@ -101,8 +101,8 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "5c1557b3", + "execution_count": 10, + "id": "c7dfafbb", "metadata": {}, "outputs": [], "source": [ @@ -117,7 +117,7 @@ " \"\"\"\n", " base64_str = conf['Photo']\n", " image = load_demo_image(base64_str, image_size, device)\n", - " res = inference(model, image)\n", + " res = inference(model_PATH, image)\n", " # add your code\n", " return {'Output': res}\n", " "