Closed archocron closed 1 year ago
Solved, i forgot to put the filename in the output parameter. It should look like this:
(anomalib_env) C:\python\anomalib>python tools/inference/openvino_inference.py --weights results/padim/mvtec/bottle/run/weights/openvino/model.bin --metadata results/padim/mvtec/bottle/run/weights/openvino/metadata.json --input datasets/MVTec/bottle/test/broken_large/000.png --output results/padim/mvtec/bottle/images/IMAGE.PNG
I downloaded the latest version of anomalib and found this error File "E:\aisoftware\Miniconda3\envs\anomalib\lib\site-packages\anomalib\data\utils\image.py", line 456, in save_image cv2.imwrite(str(filepath), image) cv2.error: opencv (4.5.5) D:\Build\ opencv \opencv-4.5.5\modules\imgcodecs\src\loadsave.cpp:730: error: (-2:Unspecified error) could not find a writer for the specified extension in function 'cv::imwrite' I know that there is no suffix in the file name here, I read your answer, you need to add IMAGE.PNG in the output, but which code should I add to it? Do I need to modify the source code? I modified the code file_path = directly in the python file E:\aisoftware\Miniconda3\envs\anomalib\lib\site-packages\anomalib\data\utils\image.py os.path.join(str(file_path), 'IMAGE.PNG') cv2.imwrite(str(file_path), image) gets some output E:\systemD\pythonProject1\anomalib\datasets\MVTec\bottle\test\broken_large\000.png E:\systemD\pythonProject1\anomalib\results\Padim\MVTec\bottle\latest\images E:\systemD\pythonProject1\anomalib\results\Padim\MVTec\bottle\latest\images\IMAGE.PNG E:\systemD\pythonProject1\anomalib\datasets\MVTec\bottle\test\broken_large\001.png E:\systemD\pythonProject1\anomalib\results\Padim\MVTec\bottle\latest\images E:\systemD\pythonProject1\anomalib\results\Padim\MVTec\bottle\latest\images\IMAGE.PNG E:\systemD\pythonProject1\anomalib\datasets\MVTec\bottle\test\broken_large\002.png How should I modify the code correctly if the image cannot be saved in the corresponding directory? Create your own directory? I put os.path.join(str(file_path), 'IMAGE.PNG') on the code that created the directory, and I can run this project, but I don't know if I changed the library source code will affect the future code. Does the code you publish on jupyter need to be modified?Give some advice
Describe the bug
I just follow all the steps to make the environment working and when i start the inference script i get the following problem:
(anomalib_env) C:\python\anomalib>python tools/inference/openvino_inference.py --weights results/padim/mvtec/bottle/run/weights/openvino/model.bin --metadata results/padim/mvtec/bottle/run/weights/openvino/metadata.json --input datasets/MVTec/bottle/test/broken_large/000.png --output results/padim/mvtec/bottle/images Traceback (most recent call last): File "C:\python\anomalib\tools\inference\openvino_inference.py", line 98, in
infer(args)
File "C:\python\anomalib\tools\inference\openvino_inference.py", line 89, in infer
visualizer.save(file_path=file_path, image=output)
File "C:\python\anomalib\src\anomalib\post_processing\visualizer.py", line 240, in save
cv2.imwrite(str(filepath), image)
cv2.error: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp:696: error: (-2:Unspecified error) could not find a writer for the specified extension in function 'cv::imwrite'
Dataset
MVTec
Model
PADiM
Steps to reproduce the behavior
I have Anaconda and i install anomalib using github instructions for the "local install" and also i have installed all the requeriments. Everything works until i try to make the inference using OpenVINO with the following command:
python tools/inference/openvino_inference.py --weights results/padim/mvtec/bottle/run/weights/openvino/model.bin --metadata results/padim/mvtec/bottle/run/weights/openvino/metadata.json --input datasets/MVTec/bottle/test/broken_large/000.png --output results/padim/mvtec/bottle/images
And I get:
Traceback (most recent call last): File "C:\python\anomalib\tools\inference\openvino_inference.py", line 98, in
infer(args)
File "C:\python\anomalib\tools\inference\openvino_inference.py", line 89, in infer
visualizer.save(file_path=file_path, image=output)
File "C:\python\anomalib\src\anomalib\post_processing\visualizer.py", line 240, in save
cv2.imwrite(str(filepath), image)
cv2.error: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp:696: error: (-2:Unspecified error) could not find a writer for the specified extension in function 'cv::imwrite'
OS information
OS information:
Expected behavior
I expect to have the inference results for the given image
Screenshots
No response
Pip/GitHub
GitHub
What version/branch did you use?
main
Configuration YAML
Logs
Code of Conduct