yangsaisai
4 years ago
| 0 | 0 | input: |
| 1 | 1 | Chinese_word: |
| 2 | value_type: "str" | |
| 3 | description: 请输入四字词语 | |
| 2 | description: "\u8BF7\u8F93\u5165\u56DB\u5B57\u8BCD\u8BED" | |
| 3 | value_type: str | |
| 4 | 4 | style: |
| 5 | value_type: "str" | |
| 6 | value_range: ['藏头诗', '藏字诗'] | |
| 7 | description: 选择生成诗句的风格 | |
| 5 | description: "\u9009\u62E9\u751F\u6210\u8BD7\u53E5\u7684\u98CE\u683C" | |
| 6 | value_range: | |
| 7 | - "\u85CF\u5934\u8BD7" | |
| 8 | - "\u85CF\u5B57\u8BD7" | |
| 9 | value_type: str | |
| 10 | '体裁': | |
| 11 | description: "选择你想要生成的古诗体裁" | |
| 12 | value_range: | |
| 13 | - "七言" | |
| 14 | - "五言" | |
| 15 | value_type: str | |
| 8 | 16 | output: |
| 9 | 17 | Poetry: |
| 10 | value_type: "str" | |
| 11 | description: 输出四句诗词 | |
| 18 | description: "\u8F93\u51FA\u4E00\u9996\u8BD7\u8BCD" | |
| 19 | value_type: str |
| 33 | 33 | |
| 34 | 34 | style = conf['style'] # value_type: str # description: some description |
| 35 | 35 | Chinese_word = conf['Chinese_word'] # value_type: str # description: some description |
| 36 | ticai = conf['体裁'] | |
| 37 | # add your code | |
| 38 | if ticai == '七言': | |
| 39 | char_len = 32 | |
| 40 | else: | |
| 41 | char_len = 24 | |
| 36 | 42 | # add your code |
| 37 | 43 | if style == '藏头诗': |
| 38 | poetry = writer.cangtou(Chinese_word) | |
| 44 | poetry_test = writer.cangtou(Chinese_word) | |
| 45 | while len(poetry_test) != char_len: | |
| 46 | poetry_test = writer.cangtou(Chinese_word) | |
| 47 | poetry = poetry_test | |
| 39 | 48 | elif conf['style'] == '藏字诗': |
| 40 | poetry = writer.hide_words(Chinese_word) | |
| 49 | poetry_test = writer.hide_words(Chinese_word) | |
| 50 | while len(poetry_test) != char_len: | |
| 51 | poetry_test = writer.cangtou(Chinese_word) | |
| 52 | poetry = poetry_test | |
| 41 | 53 | else: |
| 42 | poetry = writer.rhyme_verse() | |
| 43 | ||
| 54 | poetry_test = writer.rhyme_verse() | |
| 55 | while len(poetry_test) != char_len: | |
| 56 | poetry_test = writer.cangtou(Chinese_word) | |
| 57 | poetry = poetry_test | |
| 44 | 58 | return {'Poetry': poetry} |
| 45 | 59 | |
| 46 | 60 |
| 3 | 3 | "cell_type": "code", |
| 4 | 4 | "execution_count": 1, |
| 5 | 5 | "metadata": {}, |
| 6 | "outputs": [], | |
| 6 | "outputs": [ | |
| 7 | { | |
| 8 | "ename": "ImportError", | |
| 9 | "evalue": "cannot import name 'json_parser'", | |
| 10 | "output_type": "error", | |
| 11 | "traceback": [ | |
| 12 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
| 13 | "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", | |
| 14 | "\u001b[0;32m<ipython-input-1-d6b379403f6f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;31m# Import necessary packages\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 13\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mjson_parser\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 14\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mClient\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", | |
| 15 | "\u001b[0;31mImportError\u001b[0m: cannot import name 'json_parser'" | |
| 16 | ] | |
| 17 | } | |
| 18 | ], | |
| 7 | 19 | "source": [ |
| 8 | 20 | "# coding = utf8\n", |
| 9 | 21 | "# You can use other public modules via our Client object with module's identifier\n", |
| 41 | 53 | "metadata": {}, |
| 42 | 54 | "outputs": [ |
| 43 | 55 | { |
| 56 | "name": "stderr", | |
| 57 | "output_type": "stream", | |
| 58 | "text": [ | |
| 59 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 60 | " _np_qint8 = np.dtype([(\"qint8\", np.int8, 1)])\n", | |
| 61 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 62 | " _np_quint8 = np.dtype([(\"quint8\", np.uint8, 1)])\n", | |
| 63 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 64 | " _np_qint16 = np.dtype([(\"qint16\", np.int16, 1)])\n", | |
| 65 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 66 | " _np_quint16 = np.dtype([(\"quint16\", np.uint16, 1)])\n", | |
| 67 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 68 | " _np_qint32 = np.dtype([(\"qint32\", np.int32, 1)])\n", | |
| 69 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 70 | " np_resource = np.dtype([(\"resource\", np.ubyte, 1)])\n" | |
| 71 | ] | |
| 72 | }, | |
| 73 | { | |
| 44 | 74 | "name": "stdout", |
| 45 | 75 | "output_type": "stream", |
| 46 | 76 | "text": [ |
| 47 | 77 | "/home/jovyan/work\n", |
| 48 | "07:26:17 INFO:best_model: /home/jovyan/work/results/output_poem/best_model/model-20390\n", | |
| 78 | "02:24:31 INFO:best_model: ./results/output_poem/best_model/model-61170\n", | |
| 49 | 79 | "\n", |
| 80 | "WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:51: LSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 81 | "Instructions for updating:\n", | |
| 82 | "This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n", | |
| 83 | "02:24:31 WARNING:From /home/jovyan/work/char_rnn_model.py:51: LSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 84 | "Instructions for updating:\n", | |
| 85 | "This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n", | |
| 86 | "WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:62: MultiRNNCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 87 | "Instructions for updating:\n", | |
| 88 | "This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.\n", | |
| 89 | "02:24:31 WARNING:From /home/jovyan/work/char_rnn_model.py:62: MultiRNNCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 90 | "Instructions for updating:\n", | |
| 91 | "This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.\n", | |
| 92 | "WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", | |
| 93 | "Instructions for updating:\n", | |
| 94 | "Colocations handled automatically by placer.\n", | |
| 95 | "02:24:31 WARNING:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", | |
| 96 | "Instructions for updating:\n", | |
| 97 | "Colocations handled automatically by placer.\n", | |
| 98 | "WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:107: static_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n", | |
| 99 | "Instructions for updating:\n", | |
| 100 | "Please use `keras.layers.RNN(cell, unroll=True)`, which is equivalent to this API\n", | |
| 101 | "02:24:31 WARNING:From /home/jovyan/work/char_rnn_model.py:107: static_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n", | |
| 102 | "Instructions for updating:\n", | |
| 103 | "Please use `keras.layers.RNN(cell, unroll=True)`, which is equivalent to this API\n", | |
| 104 | "WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n", | |
| 105 | "Instructions for updating:\n", | |
| 106 | "Use standard file APIs to check for files with this prefix.\n", | |
| 107 | "02:24:31 WARNING:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n", | |
| 108 | "Instructions for updating:\n", | |
| 109 | "Use standard file APIs to check for files with this prefix.\n", | |
| 50 | 110 | "result:\n", |
| 51 | "大妃非是列,志事满黄枢。始喜封阳礼,开摩舞罢歌。\n" | |
| 111 | "大仪非是寇,谁将戚戚中。不足贤良祚,开筵始讽钟。\n" | |
| 52 | 112 | ] |
| 53 | 113 | } |
| 54 | 114 | ], |
| 85 | 145 | "execution_count": null, |
| 86 | 146 | "metadata": {}, |
| 87 | 147 | "outputs": [], |
| 88 | "source": [] | |
| 148 | "source": [ | |
| 149 | "# coding: utf-8\n", | |
| 150 | "import os\n", | |
| 151 | "import sys\n", | |
| 152 | "\n", | |
| 153 | "# Import necessary packages\n", | |
| 154 | "# from modules import json_parser\n", | |
| 155 | "from modules import Client\n", | |
| 156 | "\n", | |
| 157 | "from write_poem import start_model\n", | |
| 158 | "\n", | |
| 159 | "# Initialise Client object\n", | |
| 160 | "client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',\n", | |
| 161 | " project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',\n", | |
| 162 | " project_type='app', source_file_path='main.py', \n", | |
| 163 | " silent=True)\n", | |
| 164 | "\n", | |
| 165 | "# Make run/train/predict command alias for further use\n", | |
| 166 | "run = client.run\n", | |
| 167 | "train = client.train\n", | |
| 168 | "predict = client.predict\n", | |
| 169 | "\n", | |
| 170 | "# Make controller alias for further use\n", | |
| 171 | "controller = client.controller\n", | |
| 172 | "writer = start_model()\n", | |
| 173 | "\n", | |
| 174 | "\n", | |
| 175 | "def handle(conf):\n", | |
| 176 | " # paste your code here\n", | |
| 177 | " # path = os.getcwd() # 获取当前工作目录\n", | |
| 178 | " # print(path)\n", | |
| 179 | " if conf['style'] == ['藏头诗']:\n", | |
| 180 | " poetry = writer.cangtou(conf['Chinese_word'])\n", | |
| 181 | " elif conf['style'] == ['藏字诗']:\n", | |
| 182 | " poetry = writer.hide_words(conf['Chinese_word'])\n", | |
| 183 | " else:\n", | |
| 184 | " poetry = writer.rhyme_verse()\n", | |
| 185 | " return {\"Poetry\": poetry}\n", | |
| 186 | "\n", | |
| 187 | "\n", | |
| 188 | "# if __name__ == '__main__':\n", | |
| 189 | "# conf = {\"style\": ['藏头诗'], \"Chinese_word\": '杨赛赛'}\n", | |
| 190 | "# aa = handle(conf)\n", | |
| 191 | "# print(aa)\n" | |
| 192 | ] | |
| 193 | }, | |
| 194 | { | |
| 195 | "cell_type": "code", | |
| 196 | "execution_count": 1, | |
| 197 | "metadata": {}, | |
| 198 | "outputs": [ | |
| 199 | { | |
| 200 | "ename": "ImportError", | |
| 201 | "evalue": "No module named 'modules'", | |
| 202 | "output_type": "error", | |
| 203 | "traceback": [ | |
| 204 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
| 205 | "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", | |
| 206 | "\u001b[0;32m<ipython-input-1-d8345828f542>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;31m# Import necessary packages\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mjson_parser\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmodules\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mClient\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mwrite_poem\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mstart_model\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
| 207 | "\u001b[0;31mImportError\u001b[0m: No module named 'modules'" | |
| 208 | ] | |
| 209 | } | |
| 210 | ], | |
| 211 | "source": [ | |
| 212 | "# coding: utf-8\n", | |
| 213 | "import os\n", | |
| 214 | "import sys\n", | |
| 215 | "\n", | |
| 216 | "# Import necessary packages\n", | |
| 217 | "from modules import json_parser\n", | |
| 218 | "from modules import Client\n", | |
| 219 | "from write_poem import start_model\n", | |
| 220 | "\n", | |
| 221 | "# Initialise Client object\n", | |
| 222 | "client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',\n", | |
| 223 | " project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',\n", | |
| 224 | " project_type='app', source_file_path='main.ipynb',\n", | |
| 225 | " silent=True)\n", | |
| 226 | "\n", | |
| 227 | "# Make run/train/predict command alias for further use\n", | |
| 228 | "run = client.run\n", | |
| 229 | "train = client.train\n", | |
| 230 | "predict = client.predict\n", | |
| 231 | "\n", | |
| 232 | "# Make controller alias for further use\n", | |
| 233 | "controller = client.controller\n", | |
| 234 | "writer = start_model()\n", | |
| 235 | "\n", | |
| 236 | "\n", | |
| 237 | "def handle(conf):\n", | |
| 238 | " \"\"\"\n", | |
| 239 | " 该方法是部署之后,其他人调用你的服务时候的处理方法。\n", | |
| 240 | " 请按规范填写参数结构,这样我们就能替你自动生成配置文件,方便其他人的调用。\n", | |
| 241 | " 范例:\n", | |
| 242 | " params['key'] = value # value_type: str # description: some description\n", | |
| 243 | " 参数请放到params字典中,我们会自动解析该变量。\n", | |
| 244 | " \"\"\"\n", | |
| 245 | "\n", | |
| 246 | " style = conf['style'] # value_type: str # description: some description\n", | |
| 247 | " Chinese_word = conf['Chinese_word'] # value_type: str # description: some description\n", | |
| 248 | " # add your code\n", | |
| 249 | " if style == '藏头诗':\n", | |
| 250 | " poetry = writer.cangtou(Chinese_word)\n", | |
| 251 | " elif conf['style'] == '藏字诗':\n", | |
| 252 | " poetry = writer.hide_words(Chinese_word)\n", | |
| 253 | " else:\n", | |
| 254 | " poetry = writer.rhyme_verse()\n", | |
| 255 | "\n", | |
| 256 | " return {'Poetry': poetry}" | |
| 257 | ] | |
| 258 | }, | |
| 259 | { | |
| 260 | "cell_type": "code", | |
| 261 | "execution_count": null, | |
| 262 | "metadata": {}, | |
| 263 | "outputs": [], | |
| 264 | "source": [ | |
| 265 | "# if __name__ == '__main__':\n", | |
| 266 | "# conf = {\"style\": ['藏头诗'], \"Chinese_word\": '杨赛赛'}\n", | |
| 267 | "# aa = handle(conf)\n", | |
| 268 | "# print(aa)" | |
| 269 | ] | |
| 89 | 270 | } |
| 90 | 271 | ], |
| 91 | 272 | "metadata": { |
| 7 | 7 | - "\u85CF\u5934\u8BD7" |
| 8 | 8 | - "\u85CF\u5B57\u8BD7" |
| 9 | 9 | value_type: str |
| 10 | '体裁': | |
| 11 | description: "选择你想要生成的古诗体裁" | |
| 12 | value_range: | |
| 13 | - "七言" | |
| 14 | - "五言" | |
| 15 | value_type: str | |
| 10 | 16 | output: |
| 11 | 17 | Poetry: |
| 12 | 18 | description: "\u8F93\u51FA\u4E00\u9996\u8BD7\u8BCD" |
| 33 | 33 | |
| 34 | 34 | style = conf['style'] # value_type: str # description: some description |
| 35 | 35 | Chinese_word = conf['Chinese_word'] # value_type: str # description: some description |
| 36 | ticai = conf['体裁'] | |
| 37 | # add your code | |
| 38 | if ticai == '七言': | |
| 39 | char_len = 32 | |
| 40 | else: | |
| 41 | char_len = 24 | |
| 36 | 42 | # add your code |
| 37 | 43 | if style == '藏头诗': |
| 38 | poetry = writer.cangtou(Chinese_word) | |
| 44 | poetry_test = writer.cangtou(Chinese_word) | |
| 45 | while len(poetry_test) != char_len: | |
| 46 | poetry_test = writer.cangtou(Chinese_word) | |
| 47 | poetry = poetry_test | |
| 39 | 48 | elif conf['style'] == '藏字诗': |
| 40 | poetry = writer.hide_words(Chinese_word) | |
| 49 | poetry_test = writer.hide_words(Chinese_word) | |
| 50 | while len(poetry_test) != char_len: | |
| 51 | poetry_test = writer.cangtou(Chinese_word) | |
| 52 | poetry = poetry_test | |
| 41 | 53 | else: |
| 42 | poetry = writer.rhyme_verse() | |
| 43 | ||
| 54 | poetry_test = writer.rhyme_verse() | |
| 55 | while len(poetry_test) != char_len: | |
| 56 | poetry_test = writer.cangtou(Chinese_word) | |
| 57 | poetry = poetry_test | |
| 44 | 58 | return {'Poetry': poetry} |
| 45 | 59 | |
| 46 | 60 |
| 1 | 1 | "cells": [ |
| 2 | 2 | { |
| 3 | 3 | "cell_type": "code", |
| 4 | "execution_count": null, | |
| 4 | "execution_count": 1, | |
| 5 | "metadata": {}, | |
| 6 | "outputs": [ | |
| 7 | { | |
| 8 | "name": "stderr", | |
| 9 | "output_type": "stream", | |
| 10 | "text": [ | |
| 11 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 12 | " _np_qint8 = np.dtype([(\"qint8\", np.int8, 1)])\n", | |
| 13 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 14 | " _np_quint8 = np.dtype([(\"quint8\", np.uint8, 1)])\n", | |
| 15 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 16 | " _np_qint16 = np.dtype([(\"qint16\", np.int16, 1)])\n", | |
| 17 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 18 | " _np_quint16 = np.dtype([(\"quint16\", np.uint16, 1)])\n", | |
| 19 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 20 | " _np_qint32 = np.dtype([(\"qint32\", np.int32, 1)])\n", | |
| 21 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 22 | " np_resource = np.dtype([(\"resource\", np.ubyte, 1)])\n" | |
| 23 | ] | |
| 24 | }, | |
| 25 | { | |
| 26 | "name": "stdout", | |
| 27 | "output_type": "stream", | |
| 28 | "text": [ | |
| 29 | "05:27:14 INFO:best_model: ./results/output_poem/best_model/model-61170\n", | |
| 30 | "\n", | |
| 31 | "WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:51: LSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 32 | "Instructions for updating:\n", | |
| 33 | "This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n", | |
| 34 | "05:27:14 WARNING:From /home/jovyan/work/char_rnn_model.py:51: LSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 35 | "Instructions for updating:\n", | |
| 36 | "This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n", | |
| 37 | "WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:62: MultiRNNCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 38 | "Instructions for updating:\n", | |
| 39 | "This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.\n", | |
| 40 | "05:27:14 WARNING:From /home/jovyan/work/char_rnn_model.py:62: MultiRNNCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 41 | "Instructions for updating:\n", | |
| 42 | "This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.\n", | |
| 43 | "WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", | |
| 44 | "Instructions for updating:\n", | |
| 45 | "Colocations handled automatically by placer.\n", | |
| 46 | "05:27:14 WARNING:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", | |
| 47 | "Instructions for updating:\n", | |
| 48 | "Colocations handled automatically by placer.\n", | |
| 49 | "WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:107: static_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n", | |
| 50 | "Instructions for updating:\n", | |
| 51 | "Please use `keras.layers.RNN(cell, unroll=True)`, which is equivalent to this API\n", | |
| 52 | "05:27:14 WARNING:From /home/jovyan/work/char_rnn_model.py:107: static_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n", | |
| 53 | "Instructions for updating:\n", | |
| 54 | "Please use `keras.layers.RNN(cell, unroll=True)`, which is equivalent to this API\n", | |
| 55 | "WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n", | |
| 56 | "Instructions for updating:\n", | |
| 57 | "Use standard file APIs to check for files with this prefix.\n", | |
| 58 | "05:27:15 WARNING:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n", | |
| 59 | "Instructions for updating:\n", | |
| 60 | "Use standard file APIs to check for files with this prefix.\n" | |
| 61 | ] | |
| 62 | } | |
| 63 | ], | |
| 64 | "source": [ | |
| 65 | "import os\n", | |
| 66 | "import sys\n", | |
| 67 | "\n", | |
| 68 | "# Define root path\n", | |
| 69 | "sys.path.append('../')\n", | |
| 70 | "\n", | |
| 71 | "# Import necessary packages\n", | |
| 72 | "from modules import json_parser\n", | |
| 73 | "from modules import Client\n", | |
| 74 | "from write_poem import start_model\n", | |
| 75 | "\n", | |
| 76 | "# Initialise Client object\n", | |
| 77 | "client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',\n", | |
| 78 | " project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',\n", | |
| 79 | " project_type='app', source_file_path='main.ipynb',\n", | |
| 80 | " silent=True)\n", | |
| 81 | "\n", | |
| 82 | "# Make run/train/predict command alias for further use\n", | |
| 83 | "run = client.run\n", | |
| 84 | "train = client.train\n", | |
| 85 | "predict = client.predict\n", | |
| 86 | "\n", | |
| 87 | "# Make controller alias for further use\n", | |
| 88 | "controller = client.controller\n", | |
| 89 | "writer = start_model()\n", | |
| 90 | "\n", | |
| 91 | "\n", | |
| 92 | "def handle(conf):\n", | |
| 93 | " \"\"\"\n", | |
| 94 | " 该方法是部署之后,其他人调用你的服务时候的处理方法。\n", | |
| 95 | " 请按规范填写参数结构,这样我们就能替你自动生成配置文件,方便其他人的调用。\n", | |
| 96 | " 范例:\n", | |
| 97 | " params['key'] = value # value_type: str # description: some description\n", | |
| 98 | " 参数请放到params字典中,我们会自动解析该变量。\n", | |
| 99 | " \"\"\"\n", | |
| 100 | "\n", | |
| 101 | " style = conf['style'] # value_type: str # description: some description\n", | |
| 102 | " ticai = conf['ticai']\n", | |
| 103 | " Chinese_word = conf['Chinese_word'] # value_type: str # description: some description\n", | |
| 104 | " if ticai == '七言':\n", | |
| 105 | " char_len = 32\n", | |
| 106 | " else:\n", | |
| 107 | " char_len = 24\n", | |
| 108 | " # add your code\n", | |
| 109 | " if style == '藏头诗':\n", | |
| 110 | " poetry_test = writer.cangtou(Chinese_word)\n", | |
| 111 | " while len(poetry_test) != char_len:\n", | |
| 112 | " poetry_test = writer.cangtou(Chinese_word)\n", | |
| 113 | " poetry = poetry_test\n", | |
| 114 | " elif conf['style'] == '藏字诗':\n", | |
| 115 | " poetry_test = writer.hide_words(Chinese_word)\n", | |
| 116 | " while len(poetry_test) != char_len:\n", | |
| 117 | " poetry_test = writer.cangtou(Chinese_word)\n", | |
| 118 | " poetry = poetry_test\n", | |
| 119 | " else:\n", | |
| 120 | " poetry_test = writer.rhyme_verse()\n", | |
| 121 | " while len(poetry_test) != char_len:\n", | |
| 122 | " poetry_test = writer.cangtou(Chinese_word)\n", | |
| 123 | " poetry = poetry_test\n", | |
| 124 | " return {'Poetry': poetry}" | |
| 125 | ] | |
| 126 | }, | |
| 127 | { | |
| 128 | "cell_type": "code", | |
| 129 | "execution_count": 16, | |
| 130 | "metadata": {}, | |
| 131 | "outputs": [ | |
| 132 | { | |
| 133 | "name": "stdout", | |
| 134 | "output_type": "stream", | |
| 135 | "text": [ | |
| 136 | "{'Poetry': '我师当主士,是庆悬林端。小妇买林事,墨山无所传。'}\n" | |
| 137 | ] | |
| 138 | } | |
| 139 | ], | |
| 140 | "source": [ | |
| 141 | "if __name__ == '__main__':\n", | |
| 142 | " conf = {\"style\": '藏头诗', \"Chinese_word\": '我是小墨', 'ticai':'五言'}\n", | |
| 143 | " aa = handle(conf)\n", | |
| 144 | " print(aa)\n", | |
| 145 | "# print(len(aa['Poetry']))" | |
| 146 | ] | |
| 147 | }, | |
| 148 | { | |
| 149 | "cell_type": "code", | |
| 150 | "execution_count": 1, | |
| 5 | 151 | "metadata": {}, |
| 6 | 152 | "outputs": [], |
| 7 | 153 | "source": [ |
| 37 | 183 | }, |
| 38 | 184 | { |
| 39 | 185 | "cell_type": "code", |
| 40 | "execution_count": null, | |
| 41 | "metadata": {}, | |
| 42 | "outputs": [], | |
| 186 | "execution_count": 2, | |
| 187 | "metadata": {}, | |
| 188 | "outputs": [ | |
| 189 | { | |
| 190 | "name": "stderr", | |
| 191 | "output_type": "stream", | |
| 192 | "text": [ | |
| 193 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 194 | " _np_qint8 = np.dtype([(\"qint8\", np.int8, 1)])\n", | |
| 195 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 196 | " _np_quint8 = np.dtype([(\"quint8\", np.uint8, 1)])\n", | |
| 197 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 198 | " _np_qint16 = np.dtype([(\"qint16\", np.int16, 1)])\n", | |
| 199 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 200 | " _np_quint16 = np.dtype([(\"quint16\", np.uint16, 1)])\n", | |
| 201 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 202 | " _np_qint32 = np.dtype([(\"qint32\", np.int32, 1)])\n", | |
| 203 | "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", | |
| 204 | " np_resource = np.dtype([(\"resource\", np.ubyte, 1)])\n" | |
| 205 | ] | |
| 206 | }, | |
| 207 | { | |
| 208 | "name": "stdout", | |
| 209 | "output_type": "stream", | |
| 210 | "text": [ | |
| 211 | "/home/jovyan/work\n", | |
| 212 | "02:24:31 INFO:best_model: ./results/output_poem/best_model/model-61170\n", | |
| 213 | "\n", | |
| 214 | "WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:51: LSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 215 | "Instructions for updating:\n", | |
| 216 | "This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n", | |
| 217 | "02:24:31 WARNING:From /home/jovyan/work/char_rnn_model.py:51: LSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 218 | "Instructions for updating:\n", | |
| 219 | "This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n", | |
| 220 | "WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:62: MultiRNNCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 221 | "Instructions for updating:\n", | |
| 222 | "This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.\n", | |
| 223 | "02:24:31 WARNING:From /home/jovyan/work/char_rnn_model.py:62: MultiRNNCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n", | |
| 224 | "Instructions for updating:\n", | |
| 225 | "This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.\n", | |
| 226 | "WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", | |
| 227 | "Instructions for updating:\n", | |
| 228 | "Colocations handled automatically by placer.\n", | |
| 229 | "02:24:31 WARNING:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", | |
| 230 | "Instructions for updating:\n", | |
| 231 | "Colocations handled automatically by placer.\n", | |
| 232 | "WARNING:tensorflow:From /home/jovyan/work/char_rnn_model.py:107: static_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n", | |
| 233 | "Instructions for updating:\n", | |
| 234 | "Please use `keras.layers.RNN(cell, unroll=True)`, which is equivalent to this API\n", | |
| 235 | "02:24:31 WARNING:From /home/jovyan/work/char_rnn_model.py:107: static_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n", | |
| 236 | "Instructions for updating:\n", | |
| 237 | "Please use `keras.layers.RNN(cell, unroll=True)`, which is equivalent to this API\n", | |
| 238 | "WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n", | |
| 239 | "Instructions for updating:\n", | |
| 240 | "Use standard file APIs to check for files with this prefix.\n", | |
| 241 | "02:24:31 WARNING:From /usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n", | |
| 242 | "Instructions for updating:\n", | |
| 243 | "Use standard file APIs to check for files with this prefix.\n", | |
| 244 | "result:\n", | |
| 245 | "大仪非是寇,谁将戚戚中。不足贤良祚,开筵始讽钟。\n" | |
| 246 | ] | |
| 247 | } | |
| 248 | ], | |
| 43 | 249 | "source": [ |
| 44 | 250 | "from write_poem import start_model\n", |
| 45 | 251 | "\n", |
| 118 | 324 | "# aa = handle(conf)\n", |
| 119 | 325 | "# print(aa)\n" |
| 120 | 326 | ] |
| 121 | }, | |
| 122 | { | |
| 123 | "cell_type": "code", | |
| 124 | "execution_count": null, | |
| 125 | "metadata": {}, | |
| 126 | "outputs": [], | |
| 127 | "source": [] | |
| 128 | 327 | } |
| 129 | 328 | ], |
| 130 | 329 | "metadata": { |
| 0 | PyWavelets==1.0.2 | |
| 1 | cloudpickle==0.8.0 | |
| 2 | torchvision==0.2.2.post3 | |
| 3 | nltk==3.4 | |
| 0 | ipdb==0.13.2 | |
| 1 | toolz==0.9.0 | |
| 2 | networkx==2.2 | |
| 3 | scikit-image==0.14.1 | |
| 4 | joblib==0.14.1 | |
| 5 | pycparser==2.20 | |
| 6 | opencv-contrib-python==4.4.0.42 | |
| 7 | et-xmlfile==1.0.1 | |
| 8 | appdirs==1.4.4 | |
| 9 | retrying==1.3.3 | |
| 10 | CairoSVG==2.5.2 | |
| 11 | jmespath==0.10.0 | |
| 4 | 12 | pydot==1.4.1 |
| 13 | certipy==0.1.3 | |
| 14 | jdcal==1.4.1 | |
| 15 | cryptography==3.2.1 | |
| 16 | imbalanced-learn==0.6.2 | |
| 17 | openpyxl==2.6.4 | |
| 18 | filelock==3.0.12 | |
| 19 | sacremoses==0.0.45 | |
| 20 | tokenizers==0.5.2 | |
| 21 | unification==0.2.2 | |
| 22 | python-jsonrpc-server==0.0.1 | |
| 23 | click==7.1.2 | |
| 24 | imgaug==0.2.6 | |
| 25 | jieba==0.42.1 | |
| 26 | packaging==20.9 | |
| 27 | defusedxml==0.7.1 | |
| 28 | tf-slim==1.1.0 | |
| 29 | word2vec==0.10.6 | |
| 30 | calysto==1.0.6 | |
| 31 | s3transfer==0.3.3 | |
| 32 | configparser==4.0.2 | |
| 33 | botocore==1.19.25 | |
| 34 | tqdm==4.46.1 | |
| 35 | Shapely==1.7.0 | |
| 36 | pyOpenSSL==20.0.1 | |
| 37 | numpyencoder==0.3.0 | |
| 38 | pyrsistent==0.17.3 | |
| 39 | oauthlib==3.1.0 | |
| 40 | pygame==2.0.1 | |
| 41 | gym==0.17.2 | |
| 42 | moviepy==1.0.3 | |
| 43 | minepy==1.2.4 | |
| 44 | imageio==2.8.0 | |
| 45 | cssselect2==0.3.0 | |
| 46 | sentencepiece==0.1.91 | |
| 47 | boto3==1.16.25 | |
| 48 | dask==0.20.0 | |
| 49 | sympy==1.6.2 | |
| 50 | argon2-cffi==20.1.0 | |
| 51 | tensorflow-estimator==1.13.0 | |
| 52 | torchvision==0.5.0+cpu | |
| 53 | regex==2021.4.4 | |
| 54 | torch==1.4.0+cpu | |
| 5 | 55 | xlrd==1.2.0 |
| 56 | Augmentor==0.2.8 | |
| 57 | Cython==0.29.20 | |
| 58 | kanren==0.2.3 | |
| 59 | pyenchant==3.1.1 | |
| 60 | imageio-ffmpeg==0.4.4 | |
| 61 | svgwrite==1.3.1 | |
| 62 | distlib==0.3.1 | |
| 63 | pytorch-pretrained-bert==0.6.2 | |
| 64 | mpmath==1.2.1 | |
| 65 | importlib-resources==3.2.1 | |
| 66 | PyAudio==0.2.11 | |
| 67 | transformers==2.5.1 | |
| 68 | pyglet==1.5.0 | |
| 69 | baytune==0.3.10 | |
| 70 | zipp==1.2.0 | |
| 71 | tensorboardX==2.0 | |
| 72 | yellowbrick==1.1 | |
| 73 | mock==2.0.0 | |
| 74 | importlib-metadata==2.1.1 | |
| 75 | cairocffi==1.1.0 | |
| 76 | metakernel==0.27.5 | |
| 77 | multipledispatch==0.6.0 | |
| 78 | plotly==4.8.1 | |
| 79 | async-generator==1.10 | |
| 80 | proglog==0.1.9 | |
| 81 | torchtext==0.6.0 | |
| 82 | PyWavelets==1.0.1 | |
| 83 | cffi==1.14.5 | |
| 84 | rouge==1.0.0 | |
| 85 | attrs==21.2.0 | |
| 86 | func-timeout==4.3.5 | |
| 87 | nltk==3.5 | |
| 88 | tinycss2==1.0.2 | |
| 89 | cloudpickle==0.6.1 | |
| 6 | 90 | jupyterlab-server==0.2.0 |
| 7 | python-jsonrpc-server==0.0.1 | |
| 8 | dask==1.1.4 | |
| 9 | Shapely==1.6.4.post2 | |
| 10 | jieba==0.39 | |
| 11 | attrs==19.1.0 | |
| 12 | networkx==2.2 | |
| 13 | imageio==2.5.0 | |
| 14 | tensorflow-estimator==1.13.0 | |
| 15 | pyrsistent==0.14.11 | |
| 16 | toolz==0.9.0 | |
| 17 | torch==1.0.1.post2 | |
| 18 | mock==2.0.0 | |
| 19 | Cython==0.29.6 | |
| 20 | word2vec==0.10.2 | |
| 21 | scikit-image==0.14.2 | |
| 22 | tqdm==4.31.1 | |
| 23 | defusedxml==0.5.0 | |
| 24 | singledispatch==3.4.0.3 | |
| 25 | imgaug==0.2.8 | |
| 91 | minio==5.0.10 | |
| 92 | graphviz==0.14 |