Media-Smart / vedastr

A scene text recognition toolbox based on PyTorch
Apache License 2.0
534 stars 100 forks source link

inference.py replacing demo.py expects an image not a directory like before with demo.py #16

Closed gussmith closed 4 years ago

gussmith commented 4 years ago

vedastr$ python tools/inference.py configs/small_satrn.py pretrained/Small-SATRN.pth ../../data/ICDAR15-Word_Recognition/ch4_test_word_images_gt

2020-07-29 12:11:45,601 - INFO - Use GPU 0
2020-07-29 12:11:45,601 - INFO - Set cudnn deterministic False
2020-07-29 12:11:45,601 - INFO - Set cudnn benchmark True
2020-07-29 12:11:45,601 - INFO - Set seed 1111
2020-07-29 12:11:45,601 - INFO - Build model
2020-07-29 12:11:45,605 - INFO - GResNet init weights
2020-07-29 12:11:45,907 - INFO - TransformerEncoder init weights
2020-07-29 12:11:46,358 - INFO - TransformerDecoder init weights
2020-07-29 12:11:46,453 - INFO - TransformerHead init weights
2020-07-29 12:11:48,626 - INFO - Load checkpoint from pretrained/Small-SATRN.pth
Traceback (most recent call last):
  File "tools/inference.py", line 41, in <module>
    main()
  File "tools/inference.py", line 35, in main
    image = Image.open(args.image)
  File "/home/olivier/code/anaconda3/envs/vedastr/lib/python3.6/site-packages/PIL/Image.py", line 2766, in open
    fp = builtins.open(filename, "rb")
IsADirectoryError: [Errno 21] Is a directory: '../../data/ICDAR15-Word_Recognition/ch4_test_word_images_gt'
ChaseMonsterAway commented 4 years ago

Yes, the inference.py process an image now.

gussmith commented 4 years ago

OK.I will change it back in my branch then. I found it more useful to have the possibility to run through a series of images in a directory than one image at a time. If one wants to test only one image, it is always possible to place only one image in a directory. The reverse is not true though... Regardless, thanks for making this available!

ChaseMonsterAway commented 4 years ago

I have added this feature. Now inference.py support both dir path and file path