1. 下载安装
git clone https://github.com/deepklarity/jupyter-text2code.git
cd jupyter-text2code
pip install .
2. 打开jupyter notebook
jupyter notebook
- If installation happened successfully, then for the first time, Universal Sentence Encoder model will be downloaded from
tensorflow_hub
.
3. 解决下载Universal Sentence Encoder超时
但是文件很大 https://tfhub.dev/google/universal-sentence-encoder/4 报超时错误,因此要下载到本地先
下载后,保存本地位置设置如下:
import hashlib
import os
os.environ["TFHUB_CACHE_DIR"] = '/home/jordan/.cache/tfhub_modules'
handle = "https://tfhub.dev/google/universal-sentence-encoder/4"
hashlib.sha1(handle.encode("utf8")).hexdigest()
063d866c06683311b44b4992fd46003be952409c
/home/jordan/.cache/tfhub_modules/ # your cache directory
/f002061d9dee6acda3f90d591a65dbab7627f665/ # a module folder
/assets/
/variables/
/saved_model.pb
/tfhub_module.pb
"tfhub_module.pb; No such file or directory"错误
v1有,v2之后tfhub_module.pb就取消了
4. Nbextensions中选中mopp
参考:
https://medium.com/@xianbao.qian/how-to-run-tf-hub-locally-without-internet-connection-4506b850a915
https://github.com/deepklarity/jupyter-text2code