Open NotAleric opened 4 months ago
I got this problem too. I checked the read_image() function and I found that they divide the image by 255. After I divided the image(in np.array format) by 255, this problem was solved,
I got this problem too. I checked the read_image() function and I found that they divide the image by 255. After I divided the image(in np.array format) by 255, this problem was solved,
@him192021 Hi, could you please elaborate on exactly what steps you take to correctly infer an image?
@haimat
something like:
image = Image.open(path).convert("RGB")
image=np.array(image) / 255.0
In my case, the result was fine when using anomalib.data.utils.read_image. However, the result was always 100% defective when I use cv2/PIL to read the image. Then I printed the heat map and found that the image becomes strange. It seems that the OpenVINOInferencer.predict expect the input between 0 and 1.
@him192021 Thanks for your response!
Thanks for the replies @him192021 and @haimat.
In my case it still doesn't work despite rescaling the images between [0,1] so that the inference with OPENVINO works correctly.
In this image you can see how I am reading the images (normal and anomalous) with the function read_image of anomalib.data.utils.
When doing inference of the normal image, it still comes out abnormal 100% in spite of having images scaled between [0,1].
It is probably a problem with my data as they are quite complex to analyse by neural networks.
Dear Anomalib Team,
I am using Anomalib to detect anomalies in my dataset, which contains maps of displacements. I have followed the getting_started file from the notebooks section and encountered an issue during the inference phase using OpenVINO.
Here is a brief overview of my process:
Dataset and DataModule: I used the Folder class to create the datamodule with the following code:
Model Creation: I created a basic Padim model:
Training the Model: I used the following code to train the model:
The training process completed successfully.
Testing the Model: The testing phase also yielded good results:
Results:
Copiar código ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Test metric ┃ DataLoader 0 ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ image_AUROC │ 0.9957906007766724 │ │ image_F1Score │ 0.9931600689888 │ └───────────────────────────┴──────────────────────────┘
Exporting the Model to OpenVINO: I used the following code to export the model to OpenVINO:
Inference Issue: When I use the inferencer to predict a new image from the test data, the prediction always indicates a 100% probability of the image being abnormal. I used the following code for inference:
Results of Prediction:
1.0 LabelName.ABNORMAL
Dataset Verification: I have verified the number of images in each class to ensure the Folder class accesses the folders correctly:
Number of normal images: 2327 Number of abnormal images: 727
Image Shape Verification: I have checked the shape of the images at various stages:
Before using the Folder class: (768, 1366, 4) In the Folder class: torch.Size([3, 768, 1366]) In the test datamodule: torch.Size([3, 768, 1366]) Transposed for OpenVINO inference: (1366, 768, 3)
Installation: I installed Anomalib from source using the following commands in a new conda environment:
Despite achieving good results during testing with various models (Dfm, PathCore, Padim), the inference using OpenVINO consistently fails, indicating the problem is likely not with the model itself. I have tested with many images and used various methods for loading the images (from the Folder datamodule and directly from my original folder), but the issue persists.
I dont know if the problem is related with the dataset or even if the model is overfiiting.
I have attached a file with an example from my dataset in case the problem is related to the images.
I would appreciate any guidance or suggestions you could provide to resolve the inference issue with OpenVINO.
Thank you for your assistance.
Best regards, Alex