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

running code without CUDA #26

Closed
FrancescaCi opened this issue Feb 9, 2022 · 19 comments
Closed

running code without CUDA #26

FrancescaCi opened this issue Feb 9, 2022 · 19 comments

Comments

@FrancescaCi
Copy link

Hi,
I am trying to perform the test of your great project with the default images, but I need to perform on CPU, is it possible? and if it is yes, How?
For now I removed net.cuda(), and I put cpu on checkpoint = torch.load(checkpoint_filepath, map_location='cpu'), but the result of batch-size is 0, what can be the problem?

Thank you so much for your support!

@sjmoran
Copy link
Owner

sjmoran commented Feb 9, 2022

Thank you for your interest in this work. It should be possible to run on CPU, although it might be quite slow. The calls that you have made i.e. remove net.cuda() and loading onto the cpu would have been my suggestion, but they appear not to have worked for you. Can you provide more detail please on the batch size 0 issue? Does this mean you getting back no data from the data loader?

@FrancescaCi
Copy link
Author

Sure, The error is that one:
2022-02-09 14:19:26,374 INFO ##############################
2022-02-09 14:19:26,374 INFO Loading Adobe5k dataset ...
/home/francescadigiacomo/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py:478: UserWarning: This DataLoader will create 10 worker processes in total. Our suggested max number of worker in current system is 8, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
warnings.warn(_create_warning_msg(
2022-02-09 14:19:26,375 INFO Performing inference with images in directory: ./adobe5k_dpe/
0
0
Traceback (most recent call last):
File "main.py", line 352, in
main()
File "main.py", line 128, in main
inference_evaluator.evaluate(net, epoch=0)
File "path/CURL/metric.py", line 153, in evaluate
psnr_avg = psnr_avg / num_batches
ZeroDivisionError: float division by zero

@sjmoran
Copy link
Owner

sjmoran commented Feb 9, 2022

I don't think this is an issue with running on the CPU. I believe it is to do with the structure of the inference directory. Can you please show the directory structure you have.

@FrancescaCi
Copy link
Author

5c70bbb3-a420-4e92-bac2-eba9790810be

@FrancescaCi
Copy link
Author

Screenshot from 2022-02-09 14-29-28

@sjmoran
Copy link
Owner

sjmoran commented Feb 9, 2022

Thanks, can you also share the command you enter at the command line?

@FrancescaCi
Copy link
Author

python3 main.py --inference_img_dirpath=./adobe5k_dpe/ --checkpoint_filepath=./pretrained_models/adobe_dpe/curl_validpsnr_23.073045286204017_validloss_0.0701291635632515_testpsnr_23.584083321292365_testloss_0.061363041400909424_epoch_510_model.pt

the difference with your suggestion is :/pretrained_models/adobe_dpe, because from git clone there are not the models inside pretrained_models

@sjmoran
Copy link
Owner

sjmoran commented Feb 9, 2022

Got it, so I suspect I know the problem here. The code will look in curl_example_test_input for the images. It does this as in line 298 of data.py it is looking for a directory with "input" in the name - see here. The images listed in images_inference.txt are not those in curl_example_test_input. To get this to work you should add into images_inference.txt those image file names that are in curl_example_test_input, removing the extensions.

@FrancescaCi
Copy link
Author

Good, I will try you suggestions, thank you so much. Another questions, please. From you point of view, is it possible to use your model and apply them with a cpp implementation? Do you know if could be some issue moving from python to cpp for your implementation?

@FrancescaCi
Copy link
Author

Sorry, I followed your suggestion but it seems to not work with the same result
image
image
image

@sjmoran
Copy link
Owner

sjmoran commented Feb 9, 2022

Change this to img_id = file.split(".")[0]

@FrancescaCi
Copy link
Author

Thank you so much, but another problem occurred:
image
image
What do you think can be the issue?

@sjmoran
Copy link
Owner

sjmoran commented Feb 9, 2022

What is the contents of img_filepath? Try and print it out to debug: print(img_filepath)

@FrancescaCi
Copy link
Author

image
it seems correct, but it returns the same issue

@sjmoran
Copy link
Owner

sjmoran commented Feb 9, 2022

input_img_filepath has no root directory or path attached to it, so the loading function is unable to find the image

@sjmoran
Copy link
Owner

sjmoran commented Feb 9, 2022

Good, I will try you suggestions, thank you so much. Another questions, please. From you point of view, is it possible to use your model and apply them with a cpp implementation? Do you know if could be some issue moving from python to cpp for your implementation?

Yes, my suggested approach is to compile the model to Onnx and that will allow you to inference it from a cpp application. More detail here.

@FrancescaCi
Copy link
Author

Hi,
thank you so much for your suggestions about Cpp implementation, for the path problem, I tried this command, forcing the directory from the command but it is not able to find the image, where can I include the directory?
python3 main.py --inference_img_dirpath=/home/francescadigiacomo/inventia-image-tools/TEST_IMAGE_ENHANCEMENT/linux_inventia/CURL/adobe5k_dpe/ --checkpoint_filepath=/home/francescadigiacomo/inventia-image-tools/TEST_IMAGE_ENHANCEMENT/linux_inventia/CURL/pretrained_models/curl_validpsnr_23.073045286204017_validloss_0.0701291635632515_testpsnr_23.584083321292365_testloss_0.061363041400909424_epoch_510_model.pt

image

@sjmoran
Copy link
Owner

sjmoran commented Feb 10, 2022

I will need a little more debug info from you to help. What are the contents of this?

@sjmoran
Copy link
Owner

sjmoran commented Feb 14, 2022

Closing due to inactivity

@sjmoran sjmoran closed this as completed Feb 14, 2022
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

2 participants