簡體   English   中英

如何在TensorFlow中使用模型Inception.tgz?

[英]How do I use the model Inception.tgz in TensorFlow?

我剛剛從tensorflow.org下載了inception.tgz文件,網址為http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz 但是,我不知道我應該在哪里提取這個。

此外,當我使用models / image / imagenet / classify_image.py腳本獲取模型時,重新啟動后模型未保存,因此我必須通過相同的腳本再次下載它。 我有時需要使用它我沒有連接到互聯網,所以每次我需要分類時下載模型對我來說並不理想。 我怎樣才能一勞永逸地堅持這個模型?

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

我無法對你的問題發表評論,因為我還沒有足夠的學分。 那么,讓我給你一個通用的答案。

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

    a)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的部分在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)

該模型未第二次下載。 希望這可以幫助。

默認情況下,映像模型會下載到/ tmp / imagenet,但您可以通過將--model_dir命令行參數傳遞給--model_dir來設置自己的文件夾: https//github.com/tensorflow/tensorflow/blob/master /tensorflow/models/image/imagenet/classify_image.py#L56

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM