Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing without Masks #4

Closed
ghost opened this issue Jan 13, 2022 · 4 comments
Closed

Testing without Masks #4

ghost opened this issue Jan 13, 2022 · 4 comments

Comments

@ghost
Copy link

ghost commented Jan 13, 2022

Hello! And thank you for this latest work. I do apologize for this question if there is an easy answer that I have missed in the code. The inclusion of the evaluator is super helpful, but was curious if it was possible to amend the code to allow for testing when I do not have a mask of the image I wish to test, only the image, and still output the predicted mask?

@nnizhang
Copy link
Owner

You can run 'python train_test_eval.py --Training False --Testing True --Evaluation False' to predict the masks only from test images.

@ghost
Copy link
Author

ghost commented Jan 14, 2022

Thank you for the quick reply! and I do apologize for a follow up, when attempting to run that code with only the image in the test folder and no matching mask in the mask folder this is the error it throws:

adopt transformer encoder for tokens-to-token
Model loaded from ./pretrained_model/80.7_T2T_ViT_t_14.pth.tar
Model loaded from checkpoint/RGB_VST.pth

                   Starting testing:
                       dataset: DUTS
                       Testing size: 1
                   
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:1806: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
  warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
dataset:DUTS, cost:70.75262069702148
eval[MAE]:DUTS/DUTS-TE dataset with RGB_VST method.
Traceback (most recent call last):
  File "train_test_eval.py", line 47, in <module>
    main.evaluate(args)
  File "/content/VST/RGB_VST/Evaluation/main.py", line 33, in evaluate
    print(thread.run())
  File "/content/VST/RGB_VST/Evaluation/evaluator.py", line 21, in run
    mae = self.Eval_mae()
  File "/content/VST/RGB_VST/Evaluation/evaluator.py", line 76, in Eval_mae
    for pred, gt in self.loader:
  File "/content/VST/RGB_VST/Evaluation/dataloader.py", line 31, in __getitem__
    gt = Image.open(self.label_path[item]).convert('L')
  File "/usr/local/lib/python3.7/dist-packages/PIL/Image.py", line 2843, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: './Data/DUTS/DUTS-TE/DUTS-TE-Mask/01.png'

I am hoping to find a way to remove that dependency, as I don't have the mask for the image I wish to test. Possible?

@ghost
Copy link
Author

ghost commented Jan 14, 2022

Actually, follow on, adding the training flag to that string causes this error, removing it causes the error in the first comment. Including the flag gets this error, which makes sense, I don't have any images in the training folders.

adopt transformer encoder for tokens-to-token
Model loaded from ./pretrained_model/80.7_T2T_ViT_t_14.pth.tar
        Starting training:
            Train steps: 60000
            Batch size: 11
            Learning rate: 0.0001
            Training size: 0
        
Starting epoch 1/200.
epoch:1-------lr:0.0001
Traceback (most recent call last):
  File "train_test_eval.py", line 43, in <module>
    Training.train_net(num_gpus=num_gpus, args=args)
  File "/content/VST/RGB_VST/Training.py", line 46, in train_net
    mp.spawn(main, nprocs=num_gpus, args=(num_gpus, args))
  File "/usr/local/lib/python3.7/dist-packages/torch/multiprocessing/spawn.py", line 230, in spawn
    return start_processes(fn, args, nprocs, join, daemon, start_method='spawn')
  File "/usr/local/lib/python3.7/dist-packages/torch/multiprocessing/spawn.py", line 188, in start_processes
    while not context.join():
  File "/usr/local/lib/python3.7/dist-packages/torch/multiprocessing/spawn.py", line 150, in join
    raise ProcessRaisedException(msg, error_index, failed_process.pid)
torch.multiprocessing.spawn.ProcessRaisedException: 

-- Process 0 terminated with the following error:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/torch/multiprocessing/spawn.py", line 59, in _wrap
    fn(i, *args)
  File "/content/VST/RGB_VST/Training.py", line 176, in main
    print('Epoch finished ! Loss: {}'.format(epoch_total_loss / iter_num))
ZeroDivisionError: division by zero

@ghost
Copy link
Author

ghost commented Jan 14, 2022

Annnnnnnd you can just ignore, and i'll close this. It appears only having !python train_test_eval.py --Testing True, works. including any of the other flags causes weirdness.

All good!

@ghost ghost closed this as completed Jan 14, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant