git clone --recursive https://github.com/RainYuGG/image-captioning-based-on-Screen2Words.git
- Use conda to build the environment
conda env create -f environment.yml
- Install coco-caption for evaluation (BLEU, CIDEr).
Here are some arguments of partial tuning from the configuration file that are used to build the BLIP adapter model.
-
adapter_type: "vit"
: vit adapter ("vit", "vit_grayscale") -
bert_adapter: "bottleneck_adapter"
: bert adapter ("bottleneck_adapter", "lora_adapter", or other implementations in adapterhub)- if you want to use other implementations in adapterhub, you need to simply modify the code in
loader.py
- if you want to use other implementations in adapterhub, you need to simply modify the code in
-
tune_language: false
: tune whole language model or not (True or False)
python train.py --img-dir /path/to/rico --s2w-dir /path/to/screen2words -e 30 -b 32 -p 15
python eval.py -ckpt /path/to/checkpoint
python generater.py --img-dir /path/to/rico python train.py -ckpt /path/to/checkpoint --image_id 54137
To properly obtain the CIDEr Score in eval.py
, you need to install the coco_caption package. Follow the steps below to install it:
Clone the coco_caption
repository and navigate to the cloned directory:
cd coco_caption
bash get_stanford_models.sh
pip install gensim
- Download the latest version of Java 8 from the Oracle website: Java 8
- Copy the downloaded file to your system and extract it with the following commands:
sudo cp jdk-xxxxx_linux-x64_bin.tar.gz /opt
cd /opt
sudo mkdir java
sudo chown ${USER}:${USER} java
sudo tar -zxvf jdk-xxxxx_linux-x64_bin.tar.gz -C /opt/java
- Set the environment variable in
~/.bashrc
by adding the following lines:
#set java environment
export JAVA_HOME=/opt/java/jdk1.8.xx
export PATH=${JAVA_HOME}/bin:${PATH}
- Source the
.bashrc
file to apply the changes:
source ~/.bashrc
- Verify that Java is installed by checking the version:
java -version
To install WMD, run the following command:
bash get_google_word2vec_model.sh
To run the demo, execute the following command:
python scorer.py
Make sure to run the demo after the installation to confirm that everything works as expected.