mtailanian / uflow

GNU Affero General Public License v3.0
22 stars 4 forks source link

Question: Dataset Format #4

Closed vmiller987 closed 3 weeks ago

vmiller987 commented 3 weeks ago

Hello, thank you for adding the aupro checkpoint.

I have a few questions in regards to adding an external dataset. I have a dataset of x-ray images of tubes that are filled with a material and I am trying to build a model that can spot the defects. (One of the obvious defects is foreign material in the fill that stand out in the x-ray.)

Would you be able to provide a bit more insight into how properly setup an external dataset? Does uflow require labeled ground truth masks and for them to be accurate? Does uflow require square images? (1028x1028). My current dataset is ~110x2048, and I have currently just padded it to 2048x2048 in order to make it run. I planned on circling back to this after I got it working with my dataset.

I have currently put my dataset into /uflow/data/mvtec/burster/ and created a train, test, and ground_truth folder. I created dummy masks currently because I do not have masks.

I created a burster.yaml config file, and I had to update mvtec_debug_images.yaml.

I am able to train and validate on Epoch 0, but then it provides an error around the metrics. ValueError: Only one class present in y_true. ROC AUC score is not defined in that case. I am working through this. This is either an issue with my dummy ground masks, or I have made a mistake in my validation set.

Thank you for taking the time to deal with the issues. Hopefully this makes sense. I am new with unsupervised learning and trying to learn as much as I can.

mtailanian commented 3 weeks ago

Hello @vmiller987 I'll try to give some insights on all your questions:

Does uflow require labeled ground truth masks and for them to be accurate?

Ground truth masks are only used for evaluation. Training is done only using normal samples (no defects).

Does uflow require square images? (1028x1028). My current dataset is ~110x2048, and I have currently just padded it to 2048x2048 in order to make it run. I planned on circling back to this after I got it working with my dataset.

The first stage of U-Flow is using a pre-trained feature extractor. Let's say we use MCait. In this case, the input size is 448x448. If you plug an image of 2048x2048, it will be resized to 448x448, thus significantly reducing the resolution. As the original height of your image is small, my recommendation would be to divide the image into square tiles, run U-Flow per tile, and merge the results. For example, you could pad from 110 to 448 (or to 256 if you use resnet-based feature extractors). Also, you could use some overlap between tiles

I am able to train and validate on Epoch 0, but then it provides an error around the metrics. ValueError: Only one class present in y_true. ROC AUC score is not defined in that case.

This error means exactly what is written here. In y_true you only have one class. This is because you put only black masks (zeroed values), so all pixels are labeled as normal. AUROC can only be defined when you have 2 classes (normal and anomalies, zeros and ones). To fix this you can 1. put real labels and make sure you have both normal and anomalous examples in the validation set, or 2. comment out the metrics computations from the training process. Anyways, if you have dummy labels, the metrics would have no meaning...

Hope it helped

vmiller987 commented 3 weeks ago

Thanks for the information. I have learned quite a bit over the last 2 weeks on unsupervised learning. Thank you for posting your work on Uflow.