VamosC / CLIP4STR

An implementation of "CLIP4STR: A Simple Baseline for Scene Text Recognition with Pre-trained Vision-Language Model".
Apache License 2.0
90 stars 12 forks source link

Issue with inference ! #15

Closed hung2003oke closed 1 month ago

hung2003oke commented 1 month ago

Hi @VamosC . Thanks for great work ! i'm using your project for my school project . but when i run python3 read.py checkpoint /mnt/d/Users/Downloads/ocr_project-dev/modules/clip4str_base16x16_d70bde1f2d.ckpt --images_path /mnt/d/Users/Downloads/ocr_project-dev/modules/misc/test_image/image_1576.jpeg --device cuda . i encountered an error raise ValueError(f'mutable default {type(f.default)} for field ' ValueError: mutable default <class 'hydra.conf.JobConf.JobConfig.OverrideDirname'> for field override_dirname is not allowed: use default_factory

Can you help me? Once a gain , thanks @VamosC !

mzhaoshuai commented 1 month ago

seems nothing wrong.

What are your OS and python version?

hung2003oke commented 1 month ago

@mzhaoshuai i'm using python 3.11.9 and Ubuntu 20.04.6 LTS

mzhaoshuai commented 1 month ago

@hung2003oke Could u plz try python version 3.8.*?

https://colab.research.google.com/drive/1pS-fsCOX_ef2s5pgJ9D1IVMd2P4b7S1F?usp=sharing

Python 3.10.12 also works in a colab.

If you dont find any other thing wrong, try another version of python.

hung2003oke commented 1 month ago

@mzhaoshuai i will try again , and report back to you

hung2003oke commented 1 month ago

when i downgraded python version to 3.8.0 that error disappeared, instead there was a new error :"File "/mnt/d/Users/Downloads/ocr_project-dev/modules/strhub/models/utils.py", line 127, in parse_model_args name, value = arg.split('=', maxsplit=1) ValueError: not enough values to unpack (expected 2, got 1) " . Do you know what this error is like?

mzhaoshuai commented 1 month ago

Hi @VamosC . Thanks for great work ! i'm using your project for my school project . but when i run python3 read.py checkpoint /mnt/d/Users/Downloads/ocr_project-dev/modules/clip4str_base16x16_d70bde1f2d.ckpt --images_path /mnt/d/Users/Downloads/ocr_project-dev/modules/misc/test_image/image_1576.jpeg --device cuda . i encountered an error raise ValueError(f'mutable default {type(f.default)} for field ' ValueError: mutable default <class 'hydra.conf.JobConf.JobConfig.OverrideDirname'> for field override_dirname is not allowed: use default_factory

Can you help me? Once a gain , thanks @VamosC !

https://github.com/VamosC/CLIP4STR/blob/d18f2f4b98b7e3dc1a59a845a6940997a4e9c09c/scripts/read.sh#L12

no checkpoint after python3 read.py.

Buddy, you can first try ChatGPT for a bug like this. I always do that in my daily work.

hung2003oke commented 1 month ago

hi @mzhaoshuai , i have fixed the above error , instead there was a new error " File "/mnt/d/Users/Downloads/ocr_project-dev/modules/strhub/models/vl_str/system.py", line 75, in init kwargs["clip_pretrained"] = os.path.join(CLIP_PATH, os.path.basename(kwargs["clip_pretrained"])) NameError: name 'CLIP_PATH' is not defined " .I don't really understand why I want to run the inference file with CLIP4STR weights to test and why I also need model CLIP pretrained (the model that you have fine tuned).

mzhaoshuai commented 1 month ago

hi @mzhaoshuai , i have fixed the above error , instead there was a new error " File "/mnt/d/Users/Downloads/ocr_project-dev/modules/strhub/models/vl_str/system.py", line 75, in init kwargs["clip_pretrained"] = os.path.join(CLIP_PATH, os.path.basename(kwargs["clip_pretrained"])) NameError: name 'CLIP_PATH' is not defined " .I don't really understand why I want to run the inference file with CLIP4STR weights to test and why I also need model CLIP pretrained (the model that you have fine tuned).

Well, just use the state_dict of pre-trained CLIP model to build the model. https://github.com/VamosC/CLIP4STR/blob/d18f2f4b98b7e3dc1a59a845a6940997a4e9c09c/strhub/clip/model.py#L420

If you like, you can also build the model with a CLIP4STR model.

hung2003oke commented 1 month ago

thanks @mzhaoshuai , i have tested successfully , issue will be closed