401591c
yangsaisai 3 years ago
9 changed file(s) with 511 addition(s) and 268 deletion(s). Raw diff Collapse all Expand all
77 - "\u85CF\u5934\u8BD7"
88 - "\u85CF\u5B57\u8BD7"
99 value_type: str
10 '体裁':
11 description: "选择你想要生成的古诗体裁"
12 value_range:
13 - "七言"
14 - "五言"
15 value_type: str
1610 output:
1711 Poetry:
1812 description: "\u8F93\u51FA\u4E00\u9996\u8BD7\u8BCD"
19 value_type: str
13 value_type: str
5555 while len(poetry_test) != char_len:
5656 poetry_test = writer.cangtou(Chinese_word)
5757 poetry = poetry_test
58 return {'Poetry': poetry}
59
60
61 # if __name__ == '__main__':
62 # conf = {"style": ['藏头诗'], "Chinese_word": '杨赛赛'}
63 # aa = handle(conf)
64 # print(aa)
58 return {'Poetry': poetry}
00 {
11 "cells": [
2 {
3 "cell_type": "code",
4 "execution_count": 1,
5 "metadata": {},
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 ],
19 "source": [
20 "# coding = utf8\n",
21 "# You can use other public modules via our Client object with module's identifier\n",
22 "# and parameters.\n",
23 "# For more detailes, please see our online document - https://momodel.github.io/docs/#\n",
24 "\n",
25 "import os\n",
26 "import sys\n",
27 "\n",
28 "# Define root path\n",
29 "sys.path.append('../')\n",
30 "\n",
31 "# Import necessary packages\n",
32 "from modules import json_parser\n",
33 "from modules import Client\n",
34 "\n",
35 "# Initialise Client object\n",
36 "client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',\n",
37 " project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',\n",
38 " project_type='app', source_file_path='Untitled.ipynb')\n",
39 "\n",
40 "# Make run/train/predict command alias for further use\n",
41 "run = client.run\n",
42 "train = client.train\n",
43 "predict = client.predict\n",
44 "\n",
45 "# Make controller alias for further use\n",
46 "controller = client.controller\n",
47 "\n"
48 ]
49 },
502 {
513 "cell_type": "code",
524 "execution_count": 2,
7426 "name": "stdout",
7527 "output_type": "stream",
7628 "text": [
29 "07:53:48 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 "07:53:48 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 "07:53:48 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 "07:53:48 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 "07:53:48 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 "07:53:48 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 "# coding: utf-8\n",
66 "import os\n",
67 "import sys\n",
68 "# Define root path\n",
69 "sys.path.append('../')\n",
70 "# Import necessary packages\n",
71 "from modules import json_parser\n",
72 "from modules import Client\n",
73 "from write_poem import start_model\n",
74 "\n",
75 "# Initialise Client object\n",
76 "client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',\n",
77 " project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',\n",
78 " project_type='app', source_file_path='main.ipynb',\n",
79 " silent=True)\n",
80 "\n",
81 "# Make run/train/predict command alias for further use\n",
82 "run = client.run\n",
83 "train = client.train\n",
84 "predict = client.predict\n",
85 "\n",
86 "# Make controller alias for further use\n",
87 "controller = client.controller\n",
88 "writer = start_model()\n",
89 "\n",
90 "\n",
91 "def handle(conf):\n",
92 " \"\"\"\n",
93 " 该方法是部署之后,其他人调用你的服务时候的处理方法。\n",
94 " 请按规范填写参数结构,这样我们就能替你自动生成配置文件,方便其他人的调用。\n",
95 " 范例:\n",
96 " params['key'] = value # value_type: str # description: some description\n",
97 " 参数请放到params字典中,我们会自动解析该变量。\n",
98 " \"\"\"\n",
99 "\n",
100 " style = conf['诗词形式'] # value_type: str # description: some description\n",
101 " Chinese_word = conf['四字短语'] # value_type: str # description: some description\n",
102 " ticai = conf['体裁']\n",
103 " # add your code\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": 5,
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 = {\"诗词形式\": '藏头诗', \"四字短语\": '我是小墨', '体裁':'五言'}\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,
151 "metadata": {},
152 "outputs": [],
153 "source": [
154 "# coding = utf8\n",
155 "# You can use other public modules via our Client object with module's identifier\n",
156 "# and parameters.\n",
157 "# For more detailes, please see our online document - https://momodel.github.io/docs/#\n",
158 "\n",
159 "import os\n",
160 "import sys\n",
161 "\n",
162 "# Define root path\n",
163 "sys.path.append('../')\n",
164 "\n",
165 "# Import necessary packages\n",
166 "from modules import json_parser\n",
167 "from modules import Client\n",
168 "\n",
169 "# Initialise Client object\n",
170 "client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',\n",
171 " project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',\n",
172 " project_type='app', source_file_path='Untitled.ipynb')\n",
173 "\n",
174 "# Make run/train/predict command alias for further use\n",
175 "run = client.run\n",
176 "train = client.train\n",
177 "predict = client.predict\n",
178 "\n",
179 "# Make controller alias for further use\n",
180 "controller = client.controller\n",
181 "\n"
182 ]
183 },
184 {
185 "cell_type": "code",
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": [
77211 "/home/jovyan/work\n",
78212 "02:24:31 INFO:best_model: ./results/output_poem/best_model/model-61170\n",
79213 "\n",
189323 "# conf = {\"style\": ['藏头诗'], \"Chinese_word\": '杨赛赛'}\n",
190324 "# aa = handle(conf)\n",
191325 "# 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)"
269326 ]
270327 }
271328 ],
11 "cells": [
22 {
33 "cell_type": "code",
4 "execution_count": null,
5 "metadata": {},
6 "outputs": [],
7 "source": []
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 "04:29:29 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 "04:29:29 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 "04:29:29 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 "04:29:29 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 "04:29:29 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 "04:29:29 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 "from handler import handle"
66 ]
67 },
68 {
69 "cell_type": "code",
70 "execution_count": 16,
71 "metadata": {},
72 "outputs": [],
73 "source": [
74 "conf = {'体裁':'五言', 'style':'藏头诗', 'Chinese_word':'一二三四'}\n",
75 "res = handle(conf)"
76 ]
77 },
78 {
79 "cell_type": "code",
80 "execution_count": 23,
81 "metadata": {},
82 "outputs": [],
83 "source": [
84 "res1 = res['Poetry'].split('。')[:2]"
85 ]
86 },
87 {
88 "cell_type": "code",
89 "execution_count": 29,
90 "metadata": {},
91 "outputs": [],
92 "source": [
93 "res1 = res['Poetry'].split('。')[:2]\n",
94 "res2 = []\n",
95 "for i in res1:\n",
96 " res2.extend(i.split(','))\n",
97 "res3 = res2[0]+',\\n'+res2[1]+'。\\n'+res2[2]+',\\n'+res2[3]+'。'"
98 ]
99 },
100 {
101 "cell_type": "code",
102 "execution_count": 30,
103 "metadata": {},
104 "outputs": [
105 {
106 "data": {
107 "text/plain": [
108 "['一闻江城涯', '二月月涛中', '三湘闇北内', '四海无人同']"
109 ]
110 },
111 "execution_count": 30,
112 "metadata": {},
113 "output_type": "execute_result"
114 }
115 ],
116 "source": [
117 "res2"
118 ]
119 },
120 {
121 "cell_type": "code",
122 "execution_count": 35,
123 "metadata": {},
124 "outputs": [
125 {
126 "name": "stdout",
127 "output_type": "stream",
128 "text": [
129 "一闻江城涯,\n",
130 "二月月涛中。\n",
131 "三湘闇北内,\n",
132 "四海无人同。\n"
133 ]
134 }
135 ],
136 "source": [
137 "res3 = res2[0]+',\\n'+res2[1]+'。\\n'+res2[2]+',\\n'+res2[3]+'。'\n",
138 "print(res3)"
139 ]
8140 },
9141 {
10142 "cell_type": "code",
77 - "\u85CF\u5934\u8BD7"
88 - "\u85CF\u5B57\u8BD7"
99 value_type: str
10 '体裁':
11 description: "选择你想要生成的古诗体裁"
12 value_range:
13 - "七言"
14 - "五言"
15 value_type: str
1610 output:
1711 Poetry:
1812 description: "\u8F93\u51FA\u4E00\u9996\u8BD7\u8BCD"
19 value_type: str
13 value_type: str
00 # coding: utf-8
11 import os
22 import sys
3
3 # Define root path
4 sys.path.append('../')
45 # Import necessary packages
56 from modules import json_parser
67 from modules import Client
3334
3435 style = conf['style'] # value_type: str # description: some description
3536 Chinese_word = conf['Chinese_word'] # value_type: str # description: some description
36 ticai = conf['体裁']
37 # ticai = conf['体裁']
3738 # add your code
38 if ticai == '七言':
39 char_len = 32
40 else:
41 char_len = 24
39 # if ticai == '七言':
40 # char_len = 32
41 # else:
42 # char_len = 24
4243 # add your code
4344 if style == '藏头诗':
4445 poetry_test = writer.cangtou(Chinese_word)
45 while len(poetry_test) != char_len:
46 poetry_test = writer.cangtou(Chinese_word)
46 # while len(poetry_test) != char_len:
47 # poetry_test = writer.cangtou(Chinese_word)
4748 poetry = poetry_test
4849 elif conf['style'] == '藏字诗':
4950 poetry_test = writer.hide_words(Chinese_word)
50 while len(poetry_test) != char_len:
51 poetry_test = writer.cangtou(Chinese_word)
51 # while len(poetry_test) != char_len:
52 # poetry_test = writer.cangtou(Chinese_word)
5253 poetry = poetry_test
5354 else:
5455 poetry_test = writer.rhyme_verse()
55 while len(poetry_test) != char_len:
56 poetry_test = writer.cangtou(Chinese_word)
56 # while len(poetry_test) != char_len:
57 # poetry_test = writer.cangtou(Chinese_word)
5758 poetry = poetry_test
58 return {'Poetry': poetry}
59
60
61 # if __name__ == '__main__':
62 # conf = {"style": ['藏头诗'], "Chinese_word": '杨赛赛'}
63 # aa = handle(conf)
64 # print(aa)
59 res1 = poetry.split('。')[:2]
60 res2 = []
61 for i in res1:
62 res2.extend(i.split(','))
63 res3 = res2[0]+',\n'+res2[1]+'。\n'+res2[2]+',\n'+res2[3]+'。'
64 return {'Poetry': res3}
2626 "name": "stdout",
2727 "output_type": "stream",
2828 "text": [
29 "05:27:14 INFO:best_model: ./results/output_poem/best_model/model-61170\n",
29 "08:08:20 INFO:best_model: ./results/output_poem/best_model/model-61170\n",
3030 "\n",
3131 "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",
3232 "Instructions for updating:\n",
3333 "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",
34 "08:08:20 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",
3535 "Instructions for updating:\n",
3636 "This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n",
3737 "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",
3838 "Instructions for updating:\n",
3939 "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",
40 "08:08:20 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",
4141 "Instructions for updating:\n",
4242 "This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.\n",
4343 "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",
4444 "Instructions for updating:\n",
4545 "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",
46 "08:08:20 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",
4747 "Instructions for updating:\n",
4848 "Colocations handled automatically by placer.\n",
4949 "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",
5050 "Instructions for updating:\n",
5151 "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",
52 "08:08:20 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",
5353 "Instructions for updating:\n",
5454 "Please use `keras.layers.RNN(cell, unroll=True)`, which is equivalent to this API\n",
5555 "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",
5656 "Instructions for updating:\n",
5757 "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",
58 "08:08:21 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",
5959 "Instructions for updating:\n",
6060 "Use standard file APIs to check for files with this prefix.\n"
6161 ]
6262 }
6363 ],
6464 "source": [
65 "# coding: utf-8\n",
6566 "import os\n",
6667 "import sys\n",
67 "\n",
6868 "# Define root path\n",
6969 "sys.path.append('../')\n",
70 "\n",
7170 "# Import necessary packages\n",
7271 "from modules import json_parser\n",
7372 "from modules import Client\n",
9897 " 参数请放到params字典中,我们会自动解析该变量。\n",
9998 " \"\"\"\n",
10099 "\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",
100 " style = conf['诗词形式'] # value_type: str # description: some description\n",
101 " Chinese_word = conf['四字短语'] # value_type: str # description: some description\n",
102 " ticai = conf['体裁']\n",
103 " # add your code\n",
104104 " if ticai == '七言':\n",
105105 " char_len = 32\n",
106106 " else:\n",
126126 },
127127 {
128128 "cell_type": "code",
129 "execution_count": 16,
129 "execution_count": 5,
130130 "metadata": {},
131131 "outputs": [
132132 {
133133 "name": "stdout",
134134 "output_type": "stream",
135135 "text": [
136 "{'Poetry': '我师当主士,是庆悬林端。小妇买林事,墨山无所传。'}\n"
136 "{'Poetry': '我有被霖浪,是笑君强惩。小道见肩食,墨物不可存。'}\n"
137137 ]
138138 }
139139 ],
140140 "source": [
141141 "if __name__ == '__main__':\n",
142 " conf = {\"style\": '藏头诗', \"Chinese_word\": '我是小墨', 'ticai':'五言'}\n",
142 " conf = {\"诗词形式\": '藏头诗', \"四字短语\": '我是小墨', '体裁':'五言'}\n",
143143 " aa = handle(conf)\n",
144144 " print(aa)\n",
145145 "# print(len(aa['Poetry']))"
0 ipdb==0.13.2
1 toolz==0.9.0
2 networkx==2.2
0 async-generator==1.10
1 et-xmlfile==1.0.1
2 PyAudio==0.2.11
3 cssselect2==0.3.0
4 moviepy==1.0.3
5 jieba==0.42.1
6 pydot==1.4.1
7 retrying==1.3.3
38 scikit-image==0.14.1
9 calysto==1.0.6
10 torch==1.4.0+cpu
11 gym==0.17.2
12 cffi==1.14.5
13 svgwrite==1.3.1
14 imbalanced-learn==0.6.2
15 PyWavelets==1.0.1
16 jdcal==1.4.1
17 boto3==1.16.25
18 pyglet==1.5.0
19 botocore==1.19.25
20 oauthlib==3.1.0
21 attrs==21.2.0
22 pycparser==2.20
23 defusedxml==0.7.1
24 xlrd==1.2.0
25 mock==2.0.0
26 filelock==3.0.12
27 plotly==4.8.1
28 sacremoses==0.0.45
429 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
30 Shapely==1.7.0
31 yellowbrick==1.1
32 jmespath==0.10.0
1033 CairoSVG==2.5.2
11 jmespath==0.10.0
12 pydot==1.4.1
34 tqdm==4.46.1
1335 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
5036 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
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
7437 importlib-metadata==2.1.1
7538 cairocffi==1.1.0
39 python-jsonrpc-server==0.0.1
40 transformers==2.5.1
41 graphviz==0.14
42 func-timeout==4.3.5
43 tinycss2==1.0.2
44 pytorch-pretrained-bert==0.6.2
45 click==7.1.2
46 toolz==0.9.0
47 sympy==1.6.2
48 Augmentor==0.2.8
49 pygame==2.0.1
50 regex==2021.4.4
51 packaging==20.9
52 word2vec==0.10.6
53 configparser==4.0.2
54 dask==0.20.0
55 baytune==0.3.10
56 tf-slim==1.1.0
57 networkx==2.2
7658 metakernel==0.27.5
59 rouge==1.0.0
60 mpmath==1.2.1
61 minepy==1.2.4
62 openpyxl==2.6.4
63 importlib-resources==3.2.1
64 torchtext==0.6.0
65 appdirs==1.4.4
66 nltk==3.5
67 unification==0.2.2
7768 multipledispatch==0.6.0
78 plotly==4.8.1
79 async-generator==1.10
69 tokenizers==0.5.2
70 minio==5.0.10
71 cloudpickle==0.6.1
8072 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
73 pyrsistent==0.17.3
74 kanren==0.2.3
75 opencv-contrib-python==4.4.0.42
76 pyOpenSSL==20.0.1
77 imageio-ffmpeg==0.4.4
78 pyenchant==3.1.1
79 tensorboardX==2.0
80 tensorflow-estimator==1.13.0
81 imgaug==0.2.6
82 cryptography==3.2.1
83 Cython==0.29.20
84 s3transfer==0.3.3
85 zipp==1.2.0
86 sentencepiece==0.1.91
87 torchvision==0.5.0+cpu
9088 jupyterlab-server==0.2.0
91 minio==5.0.10
92 graphviz==0.14
89 ipdb==0.13.2
90 distlib==0.3.1
91 numpyencoder==0.3.0
92 imageio==2.8.0
11 "cells": [
22 {
33 "cell_type": "code",
4 "execution_count": null,
4 "execution_count": 1,
55 "metadata": {},
6 "outputs": [],
7 "source": []
6 "outputs": [
7 {
8 "ename": "ImportError",
9 "evalue": "No module named 'modules'",
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-739bc8dacedc>\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",
15 "\u001b[0;31mImportError\u001b[0m: No module named 'modules'"
16 ]
17 }
18 ],
19 "source": [
20 "# coding: utf-8\n",
21 "import os\n",
22 "import sys\n",
23 "\n",
24 "# Import necessary packages\n",
25 "from modules import json_parser\n",
26 "from modules import Client\n",
27 "from write_poem import start_model\n",
28 "\n",
29 "# Initialise Client object\n",
30 "client = Client(api_key='33799e1c5d6fa05fdd7dec3aa7aad868445d1c737edcf9c37fa89cb3b39cb2d9',\n",
31 " project_id='5bfd118f1afd942b66b36b30', user_ID='yangsaisai',\n",
32 " project_type='app', source_file_path='main.ipynb',\n",
33 " silent=True)\n",
34 "\n",
35 "# Make run/train/predict command alias for further use\n",
36 "run = client.run\n",
37 "train = client.train\n",
38 "predict = client.predict\n",
39 "\n",
40 "# Make controller alias for further use\n",
41 "controller = client.controller\n",
42 "writer = start_model()\n",
43 "\n",
44 "\n",
45 "def handle(conf):\n",
46 " \"\"\"\n",
47 " 该方法是部署之后,其他人调用你的服务时候的处理方法。\n",
48 " 请按规范填写参数结构,这样我们就能替你自动生成配置文件,方便其他人的调用。\n",
49 " 范例:\n",
50 " params['key'] = value # value_type: str # description: some description\n",
51 " 参数请放到params字典中,我们会自动解析该变量。\n",
52 " \"\"\"\n",
53 "\n",
54 " style = conf['诗词形式'] # value_type: str # description: some description\n",
55 " Chinese_word = conf['四字短语'] # value_type: str # description: some description\n",
56 " ticai = conf['体裁']\n",
57 " # add your code\n",
58 " if ticai == '七言':\n",
59 " char_len = 32\n",
60 " else:\n",
61 " char_len = 24\n",
62 " # add your code\n",
63 " if style == '藏头诗':\n",
64 " poetry_test = writer.cangtou(Chinese_word)\n",
65 " while len(poetry_test) != char_len:\n",
66 " poetry_test = writer.cangtou(Chinese_word)\n",
67 " poetry = poetry_test\n",
68 " elif conf['style'] == '藏字诗':\n",
69 " poetry_test = writer.hide_words(Chinese_word)\n",
70 " while len(poetry_test) != char_len:\n",
71 " poetry_test = writer.cangtou(Chinese_word)\n",
72 " poetry = poetry_test\n",
73 " else:\n",
74 " poetry_test = writer.rhyme_verse()\n",
75 " while len(poetry_test) != char_len:\n",
76 " poetry_test = writer.cangtou(Chinese_word)\n",
77 " poetry = poetry_test\n",
78 " return {'Poetry': poetry}"
79 ]
880 }
981 ],
1082 "metadata": {