0

I want to finetune the TrOCR transformer model (https://github.com/microsoft/unilm/tree/master/trocr) model with a different decoder like Bert or GPT-2 the dataset that I have (image, text) pair see the text in the following format(inside data folder)

data|
    |--- proceessed_sentence.txt
    |--- Image

I am trying to execute on google collab where I faced the issue below where I don't know how to use it Google collab
the dataset I am trying to fine-tune is like an IAM dataset for lines segment see link here The code for the mention repo [how to use it] (https://github.com/microsoft/unilm/tree/master/trocr)

!conda create -n trocr python=3.7
!conda activate trocr
!git clone https://github.com/microsoft/unilm.git
!cd unilm
!cd trocr
!pip install pybind11
!pip install -r requirements.txt
!pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" 'git+https://github.com/NVIDIA/apex.git'

Running the next cell :

!export MODEL_NAME=ft_iam
!export SAVE_PATH=/path/to/save/${MODEL_NAME}
!export LOG_DIR=log_${MODEL_NAME}
!export DATA=/path/to/data
!mkdir ${LOG_DIR}
!export BSZ=8
!export valid_BSZ=16

!CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 \
    $(which fairseq-train) \
    --data-type STR --user-dir ./ --task text_recognition --input-size 384 \
    --arch trocr_large \   # or trocr_base
    --seed 1111 --optimizer adam --lr 2e-05 --lr-scheduler inverse_sqrt \
    --warmup-init-lr 1e-8 --warmup-updates 500 --weight-decay 0.0001 --log-format tqdm \
    --log-interval 10 --batch-size ${BSZ} --batch-size-valid ${valid_BSZ} --save-dir ${SAVE_PATH} \
    --tensorboard-logdir ${LOG_DIR} --max-epoch 300 --patience 20 --ddp-backend legacy_ddp \
    --num-workers 8 --preprocess DA2 --update-freq 1 \
    --bpe gpt2 --decoder-pretrained roberta2 \ # --bpe sentencepiece --sentencepiece-model ./unilm3-cased.model --decoder-pretrained unilm ## For small models
    --finetune-from-model /path/to/model --fp16 \
    ${DATA} 

I got this issues :

File "<ipython-input-4-e347a1380d52>", line 10
    --seed 1111 --optimizer adam --lr 2e-05 --lr-scheduler inverse_sqrt \
Mohammed
  • 346
  • 1
  • 12

0 Answers0