visual-sentiment-analysis icon indicating copy to clipboard operation
visual-sentiment-analysis copied to clipboard

Inquiries about the model operation

Open Jezzffihuter opened this issue 4 years ago • 8 comments
trafficstars

Hi the author of the great model,

I am a graduate student new to computational political communication and IT technology. I am very interested in your models, and am willing to acknowledge them in my research. Still, I am a newcomer to the research practice and understandably encountered some problems. I am doing it on Windows 10 Enterprise.

With the help of Google, I have successfully installed Git Bash and changed the directory to where the download_models.sh is in. I also think that I have successfully downloaded the models via the link (though I failed in using ./download_models.sh).

  • However, I encountered some difficulties when trying to implement the second sample code. image I have set the directory, but in Git Bash, it returns ModuleNotFoundError: No module named 'torch' image

  • Meanwhile, I also tried to operate the code in PyCharm Professional 2020.01. I only added Line 11 and Line 12 to ensure the directory is where the image_list.txt in. image image It also returns ERROR: predict.py: error: the following arguments are required: image_list. While I am trying to Google for help, I suspect that this may because 1) There should be something (should it be links or paths leading to someplace locally or on web?); 2) I placed the downloaded models in the wrong directory.

I would really appreciate it if you could kindly help me to solve this problem. Starting to Learn these techs really needs a strong heart and warm help from know-hows. Many thanks for your invaluable guidance!

Jezzffihuter avatar Apr 04 '21 02:04 Jezzffihuter

Hi @Jezzffihuter . I think you need to install pytorch, follow this: https://pytorch.org/get-started/locally/

This should solve the error on git bash. The Pycharm error is a different problem; you need to configure input arguments when you run scripts from Pycharm, but I suggest proceeding with git bash.

fabiocarrara avatar Apr 06 '21 06:04 fabiocarrara

Many thanks for your reply! I have installed both torch and tqdm on Git Bash (upon its complaints). I also added these two packages to PATH (environment variables). When I am trying to run python predict.py images_list.txt --model vgg19_finetuned_all --batch_size 64 > predictions.csv, it further returns predict.py: error: unrecognized arguments: --batch_size 64. image image I Googled it, but it seems that --batch_size 64 is a code unique to the model. It would be great if you could explain a little bit about this error, appreciate!

Jezzffihuter avatar Apr 06 '21 07:04 Jezzffihuter

It should be --batch-size instead of --batch_size. My bad, I'm fixing the README.

fabiocarrara avatar Apr 06 '21 07:04 fabiocarrara

@fabiocarrara Thanks for your immediate reply.

With the fixed code, I proceeded, but with other problems.

  • Firstly, the ERROR AssertionError: Torch not compiled with CUDA enabled

image The above result is from the either of two combinations as below. image image In both the two cases above, I have installed the PyTorch with the following set-up and added the address to the environmental variable in PATH.

I understand that this may because that I have not successfully downloaded CUDA.

There is always some ERROR as I am doing on Win 10 Enterprise and GeForce 1660 Ti, and I don't think this is supported by CUDA officially (https://developer.nvidia.com/zh-cn/cuda-gpus).

image

  • Secondly, if I change the OS to windows and re-download Torch (https://pytorch.org/get-started/locally/) with the following settings, image the Linux-based version will be replaced. The AssertionError is not reported, but there are two more. image Still, when typing "python predict.py images_list.txt --model vgg19_finetuned_all --batch-size 64 > predictions.csv", it returns with ERROR AttributeError: Can't pickle local object 'main..' image May I check whether the downloaded combination (with Windows) is correct on Git Bash? If it is correct, should I try to change the code as here https://github.com/matterport/Mask_RCNN/issues/93? Actually, I am not quite familiar with your code and thus feel it hard to experiment.

Another ERROR is EOFError: Ran out of input I see that this may because I have created an empty images_list.text, however, may I consult what would be the requirement (e.g,., local or online document) and format (e.g., jpg file, some particular naming rules) https://stackoverflow.com/questions/24791987/why-do-i-get-pickle-eoferror-ran-out-of-input-reading-an-empty-file

Therefore, to which direction should I try: 1) operate with CUDA and fix the AssertionError ; 2) operate with GPU and fix the AssertionError ; 3) following the second thread of solution (can this solve the AssertionError?), my preliminary guess may be to change the code and add some content in images_list.text.

Sorry for so lengthy a note as I have tried so many times. My sincere thanks for your crucial guidance.

Jezzffihuter avatar Apr 06 '21 08:04 Jezzffihuter

you can try running the script initially without CUDA; remove all the .to('cuda') instances in the predict.py script.

The image_list.txt file should be something like this:

path/to/image1.jpg
path/to/image2.png
...

fabiocarrara avatar Apr 07 '21 11:04 fabiocarrara

@fabiocarrara Hi, thanks for your reply. Advice from you does benefit me.

  • As far as I see, there are only two .to('cuda') in predict.py script

image Please correct me if my understanding is wrong.

  • I personally suspect that there may be a minor consistency between Git Bash and Pycharm.

While the predict.py in PyCharm expects an "image_list", the Git Bash expects an "images_list.txt" when I type in ~/OneDrive - HKUST Connect/Desktop/hkust mphil sosc/Video Analysis/Data/visual-sentiment-analysis-main. image image Could this be a minor bug to fix? So should I name the image text as "images_list.txt" (I am using this for now) or "image_list.txt" when doing it on Git Bash? image

I have included a sample jpg. and png. pictures in "images_list.txt", and ensure that these claimed locations truly exist. image image image

  • However, it still returns with errors, namely AttributeError: Can't pickle local object 'main..', and EOFError: Ran out of input.

image I have Googled, but I think this may concern the file type/settings specific to the program, so I am sincerely seeking help.

While your guidance does greatly accelerate my progress, I hope this will not take a lot of time for you. Many thanks in advance. I guess we are pretty close if we get through the last few problems!

Jezzffihuter avatar Apr 08 '21 02:04 Jezzffihuter

I think you are confusing the parameter name "image_list" that is used throughout the script (args.image_list) with its value (the string "images_list.txt"). There are no inconsistencies, as you can rename your list file "asd.txt" and call the python script like this:

python predict.py asd.txt etc...

Note that when you run the script in PyCharm, it is called without any argument by default. You need to edit/create a Run Configuration to set up the arguments, e.g. asd.txt --model vgg19_finetuned_all --batch-size 64. Search on the web how to edit run configurations and add parameters for your PyCharm version.

fabiocarrara avatar Apr 12 '21 08:04 fabiocarrara

Thanks for your guidance! I will try it now.

Jezzffihuter avatar Apr 12 '21 11:04 Jezzffihuter