2016-09-24 72 views
1

我剛剛從tensorflow.org下載了inception.tgz文件,地址爲http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz。但是,我不知道我應該從哪裏提取。另外,當我使用models/image/imagenet/classify_image.py腳本來獲取模型時,模型在重新啓動後沒有保存,所以我不得不通過相同的腳本再次下載它。我有時需要使用它,因爲我沒有連接到互聯網,所以每次需要分類時下載模型都不適合我。我怎樣才能永遠堅持模型?如何在TensorFlow中使用Inception.tgz模型?

另外,如何使用.tgz初始模型?

回答

2

我不能作出評論你由於我還沒有足夠的學分,因此問題。所以讓我給你一個通用的答案。

  1. 你提到的inception-2015-12-05.tgz文件包含您需要兩個文件:

    一)imagenet_comp_graph_label_strings.txt

    B)tensorflow_inception_graph.pb

有一個許可證文件你不會需要。這兩個文件可以讓你對圖像進行預測。

  1. 您提到的部分the model was not saved after a reboot, so I had to download it again via the same script吸引了我。我從來沒有遇到過這樣的問題。立即試用:

    • 在您選擇的位置創建一個文件夾。說~/Documents
    • 當您運行python腳本classify_image.py時,請使用--model_dir標誌將模型文件目錄重定向到~/Documents。這將實質上下載並提取必要的文件到指定的位置,您可以在--model_dir標誌中使用相同的位置。

在此請看:

Aruns-MacBook-Pro:imagenet arundas$ python classify_image.py --model_dir ~/Documents/ 
>> Downloading inception-2015-12-05.tgz 100.0% 
Succesfully downloaded inception-2015-12-05.tgz 88931400 bytes. 
W tensorflow/core/framework/op_def_util.cc:332] Op BatchNormWithGlobalNormalization is deprecated. It will cease to work in GraphDef version 9. Use tf.nn.batch_normalization(). 
giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca (score = 0.89233) 
indri, indris, Indri indri, Indri brevicaudatus (score = 0.00859) 
lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens (score = 0.00264) 
custard apple (score = 0.00141) 
earthstar (score = 0.00107) 

Aruns-MacBook-Pro:imagenet arundas$ python classify_image.py --model_dir ~/Documents/ 
W tensorflow/core/framework/op_def_util.cc:332] Op BatchNormWithGlobalNormalization is deprecated. It will cease to work in GraphDef version 9. Use tf.nn.batch_normalization(). 
giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca (score = 0.89233) 
indri, indris, Indri indri, Indri brevicaudatus (score = 0.00859) 
lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens (score = 0.00264) 
custard apple (score = 0.00141) 
earthstar (score = 0.00107) 

該模型是沒有下載的第二次。 希望這有助於。

+0

謝謝!第二次下載可能是因爲我忘了關閉我所在的virtualenv。 但是,我可以直接從archieve直接將兩個必需的文件保存到/ tmp/imagenet嗎? – Woppa

+0

謝謝@阿倫,btw .. – Woppa

+0

是的,你可以使用'--model_dir'標誌來使用這些文件。 –

0

因爲它保存在臨時目錄中,每次關閉機器時,它都會被刪除。嘗試使用--model_dir參數將文件保存到目錄。

相關問題