Open PawarKishori opened 1 year ago
What should be the content of file.json along with the format? Thanks :)
After this I am getting an error:
Traceback (most recent call last):
File "inference.py", line 939, in
My assumption is the tokens expected by the code and mine and differing and hence this error... Please correct me if I am wrong. Awaiting for reply!
Source and for more details -> docs/INFERENCE.md
The json file should look something like this:
[
{
"bbox": [0.0, 0.0, 50.0, 50.0]
"text": "First"
},
{
"bbox": [52.0, 0.0, 102.0, 50.0]
"text": "next"
}
]
Let's say you have an image image_01.jpg
in folder images
.
And the corresponding json file's name should be image_01_words.json
in a folder -let's say- image_words
.
The --words_dir
flag accepts only folder path, single json file path won't work. (You should put the json file in a folder even if you want to work with single image and its corresponding json file.
Finally, your folder structure should look something like this:
images/
image_01.jpg
image_02.jpg
...
image_words/
image_01_words.json
image_02_words.json
...
Now your inference command becomes: (just for structure recognition/extraction)
## cd into `src` folder of this repo
python inference.py \
--mode recognize --structure_config_path structure_config.json \
--structure_model_path /path/to/pubtables1m_structure_detr_r18.pth \ ## <- your weights path
--structure_device cpu \ ## <- your device choice "cuda, cpu or mps"
--image_dir /path/to/images/ \ ## <- your folder path containing images
--words_dir /path/to/image_words/ \ ## <- your folder path containing corresponding json files
--out_dir ../00_outputs/ \ ## <- your output folder path
-o -l -m -v -z ## <- other flags of your choice
I hope this helps.
What should be the content of file.json along with the format? Thanks :)