You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Steps to run the COCO dataset for Image Captioning
(1) Env setup
Set up both CAFFE_ON_SPARK and SPARK_HOME per https://github.com/yahoo/CaffeOnSpark/wiki/GetStarted_standalone
export DYLD_LIBRARY_PATH=${CAFFE_ON_SPARK}/caffe-public/distribute/lib:${CAFFE_ON_SPARK}/caffe-distri/distribute/lib:/usr/local/cuda/lib:/usr/local/mkl/lib/intel64/:Python2.7.10/lib:/usr/local/cuda/lib:caffe_on_grid_archive/lib64/mkl/intel64/
export LD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}
export PATH=${SPARK_HOME}/bin:${PATH}
export PYSPARK_PYTHON=Python2.7.10/bin/python
export PYTHONPATH=$PYTHONPATH:caffeonsparkpythonapi.zip:caffe_on_grid_archive/lib64:/usr/local/cuda-7.5/lib64
export IPYTHON_ROOT=~/Python2.7.10
#-output the root directory for producing all the outputs
#-imageRoot the root input directory for all the images (required)
#-captionFile the input json which contains the image details and captions in coco format (check on mscoco.org)
#-outputFormat the format of the output file to produce the dataframe
#-imageCaptionDFDir the dataframe output dir name for images and their captions under -output, in json
#-vocabDir the vocabulary for the dataframe under -output in desired outputFormat
#-embeddingDFDir the dataframe output dir name for embedded images and their captions under -output in desired outputFormat
pushd ${CAFFE_ON_SPARK}/data/
spark-submit --master ${MASTER_URL} --deploy-mode client \
--conf spark.executor.extraClassPath=${CAFFE_ON_SPARK}/caffe-grid/target/caffe-grid-0.1-SNAPSHOT-jar-with-dependencies.jar \
--conf --driver-class-path=${CAFFE_ON_SPARK}/caffe-grid/target/caffe-grid-0.1-SNAPSHOT-jar-with-dependencies.jar \
--class com.yahoo.ml.caffe.tools.CocoDataSetConverter \
${CAFFE_ON_SPARK}/caffe-grid/target/caffe-grid-0.1-SNAPSHOT-jar-with-dependencies.jar \
-output /tmp/coco/parquet/ \
-imageRoot /tmp/coco/images/train2014/ \
-captionFile /tmp/coco/annotations/captions_train2014.json \
-outputFormat parquet \
-imageCaptionDFDir df_image_caption_train2014 \
-vocabDir vocab \
-vocabSize 8800 \
-embeddingDFDir df_embedded_train2014
ln -s /tmp/coco/parquet/vocab/part-00000 /tmp/coco/parquet/vocab.txt
popd
Run either of the steps below for running a script or notebook
(6 a) Submit the data for inference
Note that the below files also need to be shipped as shown
#-model the image-lstm pretrained model to ship
#-imagenet the image network definition
#-lstmnet the lstm network definition
#-vocab the vocabulary file (produced from above) for the given train set
#-input the input embedding produced above
#-output the path where to write the desired output
pushd ${CAFFE_ON_SPARK}/data/
ln -s ~/Python2.7.10 Python2.7.10
unzip ${CAFFE_ON_SPARK}/caffe-grid/target/caffeonsparkpythonapi.zip
rm -rf /tmp/coco/parquet/df_caption_results_train2014
spark-submit --master ${MASTER_URL} \
--conf spark.cores.max=${TOTAL_CORES} \
--conf spark.task.cpus=${CORES_PER_WORKER} \
--conf spark.driver.extraLibraryPath="${DYLD_LIBRARY_PATH}:Python2.7.10/lib" \
--conf spark.executorEnv.LD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:Python2.7.10/lib" \
--conf spark.pythonargs="-model /tmp/coco/parquet/lrcn_coco.model -imagenet lstm_deploy.prototxt -lstmnet lrcn_word_to_preds.deploy.prototxt -vocab /tmp/coco/parquet/vocab.txt -input /tmp/coco/parquet/df_embedded_train2014 -output /tmp/coco/parquet/df_caption_results_train2014" examples/ImageCaption.py
popd