Tensorflow基礎(chǔ)6-im2txt

之前用Mac跑了一下im2txt
現(xiàn)在用ubuntu虛擬機(jī)試一下, 記錄下來

參考Blog

  1. 取代碼
git clone https://github.com/tensorflow/models.git

2.安裝環(huán)境

我的設(shè)備:ubuntu14.04+GPU
TensorFlow1.0.1

相關(guān)論文 : 《Show and Tell: Lessons learned from the 2015 MSCOCO Image Captioning Challenge》
去年9月剛開源的: github

根據(jù)GitHub的readme,先安裝相關(guān)東西
1:Bazel


根據(jù)官網(wǎng)

$echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
$sudo apt-get update&& sudo
 apt-get install bazel
報(bào)錯(cuò):
有一些軟件包無法被安裝。如果您用的是 unstable發(fā)行版,這也許是因?yàn)橄到y(tǒng)無法達(dá)到您要求的狀態(tài)造成的。該版本中可能會有一些您需要的軟件
包尚未被創(chuàng)建或是它們已被從新到(Incoming)目錄移出。
下列信息可能會對解決問題有所幫助:
 
下列軟件包有未滿足的依賴關(guān)系:
 bazel : 
依賴: google-jdk 但無法安裝它 
或
                 java8-jdk但無法安裝它或
                 java8-sdk但無法安裝它或
                 oracle-java8-installer但無法安裝它
E: 
無法修正錯(cuò)誤,因?yàn)槟竽承┸浖3脂F(xiàn)狀,就是它們破壞了軟件包間的依賴關(guān)系。
 
試了網(wǎng)上的無數(shù)方法,各種換源都沒用,直到我看到官網(wǎng)的一行字:
If you want to use the JDK 7, please replace jdk1.8 with jdk1.7 and
 if you want to install the testing version of Bazel, replace stable with testing.
 
應(yīng)該是因?yàn)槲业南到y(tǒng)是ubuntu14.04,所以用的jdk7
$cat /etc/issue
Ubuntu 14.04.5 LTS \n \l

$ update-java-alternatives -l

#java-1.7.0-openjdk-amd641071
 /usr/lib/jvm/java-1.7.0-openjdk-amd64




#繼續(xù)按照官網(wǎng)
$echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.7" | sudo tee /etc/apt/sources.list.d/bazel.list
$curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
$sudo apt-get update&& sudo
 apt-get install bazel
$sudo apt-get upgrade bazel

$wget https://github.com/bazelbuild/bazel/releases/download/
0.5.0/bazel-0.5.0-installer-linux-x86_64.sh

$chmod +x bazel-0.5.0-installer-linux-x86_64.sh
$./bazel-0.5.0-installer-linux-x86_64.sh --user

$export PATH="$PATH:$HOME/bin"

#檢查自己是否安裝好了
root@cf644f163c6d:~# $HOME/bin/bazel version
Extracting Bazel installation...
Build label: 0.5.0
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/bu
ild/lib/bazel/BazelServer_deploy.jar
Build time: Fri May 26 12:11:50 2017 (1495800710)
Build timestamp: 1495800710
Build timestamp as int: 1495800710

繼續(xù)安裝另外兩個(gè)庫NumPy和 NLTK
2:NumPy

NumPy
安裝官方文檔
[https://www.scipy.org/install.html](https://www.scipy.org/install.html)
$python -m pip install --upgrade pip
$pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
測試:
$python
>>>import scipy
>>>import numpy
>>>scipy.test()
>>>numpy.test()
網(wǎng)上說也可以這么裝,不懂跟GitHub上鏈接的網(wǎng)址有什么不同
$sudo apt-get install Python-scipy
$sudo apt-get install python-numpy
$sudo apt-get install python-matplotlib

3:NLTK

Natural Language Toolkit (NLTK):
首先安裝NLTK
[http://www.nltk.org/install.html](http://www.nltk.org/install.html)
$sudo pip install -U nltk
$sudo pip install -U numpy
$python
>>> import nltk

繼續(xù)github的流程

# Location to save the MSCOCO data.
MSCOCO_DIR="${HOME}/im2txt/data/mscoco"

# Build the preprocessing script. 要把model改名成tensorflow-models
cd tensorflow-models/im2txt     

$HOME/bin/bazel build //im2txt:dow
nload_and_preprocess_mscoco

我的輸出如下:

root@cf644f163c6d:~/tensorflow-models/im2txt# /root/bin/bazel build //im2txt:dow
nload_and_preprocess_mscoco
..................
INFO: Found 1 target...
Target //im2txt:download_and_preprocess_mscoco up-to-date:
  bazel-bin/im2txt/download_and_preprocess_mscoco
INFO: Elapsed time: 5.003s, Critical Path: 0.03s

第三步比較耗時(shí),因?yàn)橛?3G的文件

# Run the preprocessing script.
bazel-bin/im2txt/download_and_preprocess_mscoco "${MSCOCO_DIR}"
1.jpg
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容