Skip to content

Instantly share code, notes, and snippets.

@behitek
Last active April 23, 2017 15:10
Show Gist options
  • Save behitek/e638bc765be947f97557420c6746314a to your computer and use it in GitHub Desktop.
Save behitek/e638bc765be947f97557420c6746314a to your computer and use it in GitHub Desktop.

Go to im2txt directory

cd models/im2txt/

Directory containing preprocessed MSCOCO data.

MSCOCO_DIR="/home/duongkk_dev/models/im2txt/im2txt/data/mscoco"

Inception v3 checkpoint file.

INCEPTION_CHECKPOINT="/home/duongkk_dev/models/im2txt/im2txt/data/inception_v3.ckpt"

Directory to save the model.

MODEL_DIR="/home/duongkk_dev/models/im2txt/im2txt/model"

Build the model.

bazel build -c opt im2txt/...

Run the training script.

bazel-bin/im2txt/train \
  --input_file_pattern="${MSCOCO_DIR}/train-?????-of-00256" \
  --inception_checkpoint_file="${INCEPTION_CHECKPOINT}" \
  --train_dir="${MODEL_DIR}/train" \
  --train_inception=false \
  --number_of_steps=1000000

Test kết quả

https://console.cloud.google.com/compute/instancesDetail/zones/asia-east1-c/instances/instance-1?project=admob-app-id-4239207165&authuser=2&duration=PT1H

  1. Chuẩn bị 1 ảnh bất kỳ ở máy tính. => Nên đổi tên ngắn gọn

  2. Nhấp biểu setting góc trên bên phải -> Upload file để upload ảnh vừa chuẩn bị.

  3. Chạy các command sau (Bỏ qua dấu #)

  • Áp dụng nếu là lần đầu tiên
#
cd models/im2txt/
#
CHECKPOINT_PATH="/home/duongkk_dev/models/im2txt/im2txt/model/train"
#
VOCAB_FILE="/home/duongkk_dev/models/im2txt/im2txt/data/mscoco/word_counts.txt"

  • Khai báo đường dẫn ảnh
# Giả sử 3.jpg là tên ảnh bạn vừa upload vào
IMAGE_FILE="/home/duongkk_dev/3.jpg"
  • Lấy kết quả
# 
bazel build -c opt im2txt/run_inference
#
bazel-bin/im2txt/run_inference \
 --checkpoint_path=${CHECKPOINT_PATH} \
 --vocab_file=${VOCAB_FILE} \
 --input_files=${IMAGE_FILE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment