日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Google开源库Image Captioning部署记录

發布時間:2025/4/16 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Google开源库Image Captioning部署记录 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Github庫:https://github.com/tensorflow/models/tree/master/research/im2txt

場景:給一張圖片,描述圖片內容。如下圖:

環境:ubuntu,記住用戶必須對目錄有權限。

1、下載開源包:git clone?https://github.com/tensorflow/models.git? ?

? ? ? 進入Im2txt子項目:cd?research/im2txt

2、安裝依賴包:

First ensure that you have installed the following required packages:

  • Bazel?(instructions)
  • Python 2.7
  • TensorFlow?1.0 or greater (instructions)
  • NumPy?(instructions)
  • Natural Language Toolkit (NLTK):
    • First install NLTK (instructions)
    • Then install the NLTK data package "punkt" (instructions)
  • Unzip

1)Bazel:?我選擇Installing using binary installer方式安裝。

? ? ?參考網址:https://docs.bazel.build/versions/master/install-ubuntu.html

2)NLTK:sudo?pip2 install?-U?nltk

? ? ?數據包安裝:進入python2

>>>import nltk >>> nltk.download("punkt")

3、準備訓練數據

3.1??MSCOCO數據集

bazel build //im2txt:download_and_preprocess_mscoco bazel-bin/im2txt/download_and_preprocess_mscoco "im2txt/data/mscoco"

準備成功如下圖:

3.2 已訓練CNN模型Inception v3 Checkpoint

wget "http://download.tensorflow.org/models/inception_v3_2016_08_28.tar.gz" tar -xvf "inception_v3_2016_08_28.tar.gz" -C im2txt/data rm "inception_v3_2016_08_28.tar.gz"

4、訓練模型

bazel build -c opt //im2txt/...

nohup bazel-bin/im2txt/train \
? --input_file_pattern="im2txt/data/mscoco/train-?????-of-00256" \
? --inception_checkpoint_file="im2txt/data/inception_v3.ckpt" \
? --train_dir="im2txt/model/train" \
? --train_inception=false \
? --number_of_steps=1000000 &

evaluation script和Fine Tune the Inception v3 Model我這里沒有去運行。有需要可參照官方介紹進行。訓練完成如下圖。

5、圖片生成文本

bazel build -c opt //im2txt:run_inference bazel-bin/im2txt/run_inference \--checkpoint_path=im2txt/model/train \--vocab_file=im2txt/data/mscoco/word_counts.txt \--input_files=im2txt/data/mscoco/raw-data/val2014/COCO_val2014_000000051008.jpg

?結果:

Captions for image COCO_val2014_000000051008.jpg:0) a cat laying on top of a laptop computer . (p=0.010717)1) a cat laying on top of a laptop keyboard . (p=0.001352)2) a cat laying on top of a laptop on a bed . (p=0.000764)

總結

以上是生活随笔為你收集整理的Google开源库Image Captioning部署记录的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。