cc38b78
user_wwq 3 years ago
4 changed file(s) with 28 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
55 output:
66 Output:
77 name: Output
8 value_type: img
8 value_type: str
99 description: ''
99
1010 model_PATH='/home/jovyan/work/src/output/models/model2000.ckpt'
1111
12 import time
13 def run_time(func):
14 def inner(model, image, question):
15 back = func(model, image, question)
16 print("Runned time: {} s".format(round((time.time() - t)/10, 3)))
17 return back
18 t = time.time()
19 return inner
20
1221 def load_demo_image(in_PATH):
1322 img = np.array(Image.open(in_PATH).convert('RGB'))[np.newaxis] / 255.0
1423 img_p = util.preprocess_images_outpainting(img)
1524 return img_p
1625
26 @run_time
1727 def inference(model_PATH, img_p):
1828 G_Z = tf.placeholder(tf.float32, shape=[None, IMAGE_SZ, IMAGE_SZ, 4], name='G_Z')
1929 G_sample = model.generator(G_Z)
3848 """
3949 base64_str = conf['Photo']
4050 image = load_demo_image(base64_str, image_size, device)
41 res = inference(model, image)
51 res = inference(model_PATH, image)
4252 # add your code
4353 return {'Output': res}
4454
22 {
33 "cell_type": "code",
44 "execution_count": 3,
5 "id": "769c9afd",
5 "id": "04c7f16a",
66 "metadata": {},
77 "outputs": [
88 {
3939 {
4040 "cell_type": "code",
4141 "execution_count": 4,
42 "id": "227c58c5",
42 "id": "0dd13c75",
4343 "metadata": {},
4444 "outputs": [],
4545 "source": [
4949 {
5050 "cell_type": "code",
5151 "execution_count": 9,
52 "id": "dc65195f",
52 "id": "649a883e",
5353 "metadata": {},
5454 "outputs": [],
5555 "source": [
6666 {
6767 "cell_type": "code",
6868 "execution_count": 8,
69 "id": "bcbe551f",
69 "id": "fba4c6ff",
7070 "metadata": {},
7171 "outputs": [],
7272 "source": [
7979 {
8080 "cell_type": "code",
8181 "execution_count": 6,
82 "id": "36fcb0d9",
82 "id": "ff900f2b",
8383 "metadata": {},
8484 "outputs": [],
8585 "source": [
100100 },
101101 {
102102 "cell_type": "code",
103 "execution_count": null,
104 "id": "b79deb86",
103 "execution_count": 10,
104 "id": "9d164058",
105105 "metadata": {},
106106 "outputs": [],
107107 "source": [
116116 " \"\"\"\n",
117117 " base64_str = conf['Photo']\n",
118118 " image = load_demo_image(base64_str, image_size, device)\n",
119 " res = inference(model, image)\n",
119 " res = inference(model_PATH, image)\n",
120120 " # add your code\n",
121121 " return {'Output': res}\n",
122122 " "
22 {
33 "cell_type": "code",
44 "execution_count": 3,
5 "id": "3c86ef8a",
5 "id": "755152e5",
66 "metadata": {},
77 "outputs": [
88 {
3939 {
4040 "cell_type": "code",
4141 "execution_count": 4,
42 "id": "87b58a5a",
42 "id": "c45b2ba8",
4343 "metadata": {},
4444 "outputs": [],
4545 "source": [
4949 {
5050 "cell_type": "code",
5151 "execution_count": 9,
52 "id": "4e963aed",
52 "id": "7eb0351a",
5353 "metadata": {},
5454 "outputs": [],
5555 "source": [
6666 {
6767 "cell_type": "code",
6868 "execution_count": 8,
69 "id": "aba8e440",
69 "id": "196069cc",
7070 "metadata": {},
7171 "outputs": [],
7272 "source": [
7979 {
8080 "cell_type": "code",
8181 "execution_count": 6,
82 "id": "bc8c0bf4",
82 "id": "e0a075d4",
8383 "metadata": {},
8484 "outputs": [],
8585 "source": [
100100 },
101101 {
102102 "cell_type": "code",
103 "execution_count": null,
104 "id": "5c1557b3",
103 "execution_count": 10,
104 "id": "c7dfafbb",
105105 "metadata": {},
106106 "outputs": [],
107107 "source": [
116116 " \"\"\"\n",
117117 " base64_str = conf['Photo']\n",
118118 " image = load_demo_image(base64_str, image_size, device)\n",
119 " res = inference(model, image)\n",
119 " res = inference(model_PATH, image)\n",
120120 " # add your code\n",
121121 " return {'Output': res}\n",
122122 " "