Opennmt-py: why need -src src-test.txt for image to text opennmt?

Created on 19 Aug 2019  路  7Comments  路  Source: OpenNMT/OpenNMT-py

i was bit confused. please once explain me, help me anyone :)

i was tried this way.

python drive/My\ Drive/OpenNMT-py/translate.py -data_type img -model drive/My\ Drive/Pretrained_Word_Embeddings/detectron_table_detection/model.pt -src_dir drive/My\ Drive/datasets/table_dataset_sample/8.jpg \
  -output pred.txt -max_length 150 -beam_size 5 -gpu 0 -verbose



i am getting same issue. i don't know what is -src_dir & -src

usage: translate.py [-h] [-config CONFIG] [-save_config SAVE_CONFIG] --model
                    MODEL [MODEL ...] [--fp32] [--avg_raw_probs]
                    [--data_type DATA_TYPE] --src SRC [--src_dir SRC_DIR]
                    [--tgt TGT] [--shard_size SHARD_SIZE] [--output OUTPUT]
                    [--report_bleu] [--report_rouge] [--report_time]
                    [--dynamic_dict] [--share_vocab]
                    [--random_sampling_topk RANDOM_SAMPLING_TOPK]
                    [--random_sampling_temp RANDOM_SAMPLING_TEMP]
                    [--seed SEED] [--beam_size BEAM_SIZE]
                    [--min_length MIN_LENGTH] [--max_length MAX_LENGTH]
                    [--max_sent_length] [--stepwise_penalty]
                    [--length_penalty {none,wu,avg}] [--ratio RATIO]
                    [--coverage_penalty {none,wu,summary}] [--alpha ALPHA]
                    [--beta BETA] [--block_ngram_repeat BLOCK_NGRAM_REPEAT]
                    [--ignore_when_blocking IGNORE_WHEN_BLOCKING [IGNORE_WHEN_BLOCKING ...]]
                    [--replace_unk] [--phrase_table PHRASE_TABLE] [--verbose]
                    [--log_file LOG_FILE]
                    [--log_file_level {CRITICAL,ERROR,WARNING,INFO,DEBUG,NOTSET,50,40,30,20,10,0}]
                    [--attn_debug] [--dump_beam DUMP_BEAM] [--n_best N_BEST]
                    [--batch_size BATCH_SIZE] [--gpu GPU]
                    [--sample_rate SAMPLE_RATE] [--window_size WINDOW_SIZE]
                    [--window_stride WINDOW_STRIDE] [--window WINDOW]
                    [--image_channel_size {3,1}]
translate.py: error: the following arguments are required: --src/-src

here docuentation (Image to text ) they said,

python translate.py -data_type img -model demo-model_acc_x_ppl_x_e13.pt -src_dir data/im2text/images \
                    -src data/im2text/src-test.txt -output pred.txt -max_length 150 -beam_size 5 -gpu 0 -verbose

-src_dir: The directory containing the images.

then why i need -src data/im2text/src-test.txt ?

we want image to text. but src why txt. what is that can any one clarify me.

Thank you all

Most helpful comment

src_dir is the path to the actual directory containing the images.
src is a text file containing the paths to the images (relative to src_dir IIRC).

All 7 comments

src_dir is the path to the actual directory containing the images.
src is a text file containing the paths to the images (relative to src_dir IIRC).

Thank you sir. got it

[2019-08-19 17:50:44,610 INFO] Translating shard 0.
/usr/local/lib/python3.6/dist-packages/torchtext/data/field.py:359: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  var = torch.tensor(arr, dtype=self.dtype, device=device)


SENT 1: None
PRED 1: <tabular> <tbody> <tr> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> </tr> <tr> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> </tr> <tr> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdn> </tr> <tr> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdn> </tr> <tr> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdn> </tr> <tr> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdn> </tr> <tr> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdn> </tr> <tr> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdy> <tdn> </tr> </tbody> </tabular>
PRED SCORE: -1.2848
PRED AVG SCORE: -0.0111, PRED PPL: 1.0111

Have a look at the example.
You have image1.jpg image2.jpg image3.jpg in some my_images directory.
src_dir is my_images
src is a text file containing:

image1.jpg
image2.jpg
image3.jpg

sir but my table image to text, showing poor results. sir please can you explain me sir.
result is,
`
img2txt.zip

Looks like you're not the one who trained this model (you would have had the same question for the preprocess stage than the translate one). Maybe you want to ask them.
Or, you can start a research discussion on the forum.

Yes sir this is for tablebank community they released pretrained model. Sir I will check it. Thank you for your kindness help.

@MuruganR96 Hi Murugan and all , did you managed to get the text out of table ? i am just getting empty table like below.
SENT 1: None

"'PRED 1:

"

PRED SCORE: -2.1803

Was this page helpful?
0 / 5 - 0 ratings