iceberg-project / Penguins

MIT License
3 stars 3 forks source link

importing module 'models' not found #7

Closed AymenFJA closed 5 years ago

AymenFJA commented 5 years ago

Hello @lmhieu612 :

I was trying to run the penguins code on Bridges and I followed your instructions and how to install all the dependencies, I followed the command example in the readme you provided and I did the following : python predict.py --gpu-ids 0 --name v3weakly_unetr_bs96_main_model_ignore_bad --epoch 300 --checkpoints_dir checkpoints_dir/checkpoints_v3weakly_unetr_bs96_main_model_ignore_bad/ --output test --testset GE --input_im /pylon5/mc3bggp/aymen/img.png

also i am using python3

and I got the following error : File "src/predicting/predict.py", line 13, in <module> from models import create_model ModuleNotFoundError: No module named 'models' am i doing something wrong ? can you help, please.

AymenFJA commented 5 years ago

any updates? :-)

bspitzbart commented 5 years ago

@lmhieu612 It looks like models.py is missing?

hieulem commented 5 years ago

Hi @AymenFJA, sorry I haven't noticed that we have an open issue.

I can't reproduce the bug. My best guess is that you need to add the folder "models" into the system path. It's running fine in my env here even though I am not doing that. I use python 2.7.

Ping me in slack so I could assist you more easily :)

AymenFJA commented 5 years ago

Hello @lmhieu612 ,

Not a problem, In the readme file the prerequisites of the Penguins code is Pythpn3 so I installed it. I will try to install python 2.7, export the path and update this ticket. Also, it would be easier for me to keep doing issue tracking and solving through GitHub.

Thanks for the help.

iparask commented 5 years ago

@AymenFJA, try to include file path to $PYTHONPATH and report back. It makes sense to include all the steps taken to create the environment

hieulem commented 5 years ago

In predict.py, can you please try adding this line: sys.path.insert(0, "./../..")

iparask commented 5 years ago

May I suggest that do export PYTHONPATH=.....:$PYTHONPATH?

AymenFJA commented 5 years ago

Steps I did base on @lmhieu612 and @iparask suggestions :

  1. Create new Conda env with Python 2.7.16 |Anaconda
  2. Installing PyTorch 0.4 and dependencies from http://pytorch.org.
  3. Install Torch vision from the source.
  4. Install python libraries visdom and dominate.
  5. Installing opencv2.
  6. Reserving one GPU node Interact -gpu on bridges.
  7. Do export PYTHONPATH=/Penguins/src:$PYTHONPATH
  8. Execute python src/predicting/predict.py --gpu_ids 0 --name v3weakly_unetr_bs96_main_model_ignore_bad --epoch 300 --checkpoints_dir 'checkpoints_dir/checkpoints_CVPR19W/' --output test --testset GE --input_im pengui.png

I got another error : Traceback (most recent call last): File "src/predicting/predict.py", line 244, in <module> a.test_single_png(opt.input_im) File "src/predicting/predict.py", line 237, in test_single_png outpng = self.png_predict(inpng) File "src/predicting/predict.py", line 105, in png_predict w,h,c = im.shape ValueError: need more than 2 values to unpack .

any idea why?

Thanks.

bspitzbart commented 5 years ago

What is your input image? Do you need the full path or at least a './'? Are you on /pylon5? Can you make it group readable and @lmhieu612 and I can take a look.

AymenFJA commented 5 years ago

@bspitzbart

My input image is from WV02-penguins images in the google drive, I extracted 256x256 and converted it to a PNG image, I verified that the image is not corrupted, also I don't think I need the full path. The error is rising from the following: w,h,c = im.shape, I tried to switch from opencv2 to opencv3 but the error is the same.

AymenFJA commented 5 years ago

I think the problem is with my PNG input image type, can you please provide me with a sample input image for testing. thanks @bspitzbart

bspitzbart commented 5 years ago

/pylon5/mc3bggp/bspitz/Penguins/Testing/Input

hieulem commented 5 years ago

I think it's very likely that you used a gray image for testing while the current model is for the RGB images.

AymenFJA commented 5 years ago

I tried one of the images that @bspitzbart sent in the dir path above, and I am getting this error :


  File "src/predicting/predict.py", line 246, in <module>
    a.test_single_png(opt.input_im)
  File "src/predicting/predict.py", line 239, in test_single_png
    outpng = self.png_predict(inpng)
  File "src/predicting/predict.py", line 141, in png_predict
    outpng = patches2png_legacy(out,w,h,opt.step,opt.size)
  File "/home/aymen/SummerRadical/Penguins/src/data_processing/m_im_util.py", line 122, in patches2png_legacy
    tif = np.zeros((1,w,h))
TypeError: 'tuple' object cannot be interpreted as an index```
hieulem commented 5 years ago

can you print what is "w" and "h" in here? they should be 256.

I guess I need an account in Bridge

AymenFJA commented 5 years ago

Hello @lmhieu612 ,

So just to be clear, i am using the same image as you stated in the Readme file, I printed both values and this is what I got :

----------------------
w = (2153, 2150, 3)
h = (2153, 2150, 3)
----------------------
AymenFJA commented 5 years ago

Hello @lmhieu612 were you able to run the code on Bridges?

Thanks.

hieulem commented 5 years ago

Hi @AymenFJA,

Please check out the minor_fix branch and see if it could help. I ran it on Bridges without any error.

AymenFJA commented 5 years ago

Sure, I will follow these instructions and update the ticket ASAP. Thanks, @lmhieu612

AymenFJA commented 5 years ago

Yes, I did git checkout to minor_fix now and it is working. Thanks, @lmhieu612 .

This ticket will be closed for now.

bspitzbart commented 5 years ago

Excellent. Thanks @Aymen afa64@scarletmail.rutgers.edu and @Hieu Le hieu.le@stonybrook.edu.

On Wed, Jun 5, 2019 at 2:53 PM Aymen Alsaadi notifications@github.com wrote:

Yes, I did git checkout to minor_fix now and it is working. Thanks, @lmhieu612 https://github.com/lmhieu612 .

This ticket will be closed for now.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iceberg-project/Penguins/issues/7?email_source=notifications&email_token=AAN5FW4WKAH7JMSJE6GIYUTPZADQNA5CNFSM4HKL5OEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXAVPVY#issuecomment-499210199, or mute the thread https://github.com/notifications/unsubscribe-auth/AAN5FW6XMKOPKLM2YN6Y5PTPZADQNANCNFSM4HKL5OEA .

AymenFJA commented 5 years ago

Sorry, based on that, can we please open a pull request for this fix to the devel branch, please ? @bspitzbart @lmhieu612

Thanks again.