953abde
user_wwq 3 years ago
2 changed file(s) with 10 addition(s) and 38 deletion(s). Raw diff Collapse all Expand all
22 {
33 "cell_type": "code",
44 "execution_count": 3,
5 "id": "820b3659",
5 "id": "2b480856",
66 "metadata": {},
77 "outputs": [
88 {
3939 {
4040 "cell_type": "code",
4141 "execution_count": 4,
42 "id": "778a8669",
42 "id": "ba1925fa",
4343 "metadata": {},
4444 "outputs": [],
4545 "source": [
4848 },
4949 {
5050 "cell_type": "code",
51 "execution_count": 9,
52 "id": "2873f942",
53 "metadata": {},
54 "outputs": [],
55 "source": [
56 "import time\n",
57 "def run_time(func):\n",
58 " def inner(model, image, question):\n",
59 " back = func(model, image, question)\n",
60 " print(\"Runned time: {} s\".format(round((time.time() - t)/10, 3)))\n",
61 " return back\n",
62 " t = time.time()\n",
63 " return inner"
64 ]
65 },
66 {
67 "cell_type": "code",
6851 "execution_count": 8,
69 "id": "40f61f2c",
52 "id": "20c88989",
7053 "metadata": {},
7154 "outputs": [],
7255 "source": [
7356 "def load_demo_image(in_PATH):\n",
7457 " img = np.array(Image.open(in_PATH).convert('RGB'))[np.newaxis] / 255.0\n",
75 " img_p = util.preprocess_images_outpainting(img)\n",
58 " img_p = src.util.preprocess_images_outpainting(img)\n",
7659 " return img_p"
7760 ]
7861 },
7962 {
8063 "cell_type": "code",
8164 "execution_count": 11,
82 "id": "d4861188",
65 "id": "5d117d25",
8366 "metadata": {},
8467 "outputs": [],
8568 "source": [
9376 {
9477 "cell_type": "code",
9578 "execution_count": 6,
96 "id": "92005cf0",
79 "id": "de6b79ae",
9780 "metadata": {},
9881 "outputs": [],
9982 "source": [
100 "@run_time\n",
10183 "def inference(model_PATH, img_p):\n",
10284 " G_Z = tf.placeholder(tf.float32, shape=[None, IMAGE_SZ, IMAGE_SZ, 4], name='G_Z')\n",
103 " G_sample = model.generator(G_Z)\n",
85 " G_sample = src.model.generator(G_Z)\n",
10486 " \n",
10587 " saver = tf.train.Saver()\n",
10688 " with tf.Session() as sess:\n",
11597 {
11698 "cell_type": "code",
11799 "execution_count": 12,
118 "id": "5863f30d",
100 "id": "35c27191",
119101 "metadata": {},
120102 "outputs": [],
121103 "source": [
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
2112 def load_demo_image(in_PATH):
2213 img = np.array(Image.open(in_PATH).convert('RGB'))[np.newaxis] / 255.0
23 img_p = util.preprocess_images_outpainting(img)
14 img_p = src.util.preprocess_images_outpainting(img)
2415 return img_p
2516
2617 def image_to_path(img):
2920 resize_img.save(path)
3021 return path
3122
32 @run_time
3323 def inference(model_PATH, img_p):
3424 G_Z = tf.placeholder(tf.float32, shape=[None, IMAGE_SZ, IMAGE_SZ, 4], name='G_Z')
35 G_sample = model.generator(G_Z)
25 G_sample = src.model.generator(G_Z)
3626
3727 saver = tf.train.Saver()
3828 with tf.Session() as sess: