nkanungo's picture
Upload 18 files
6c267c2
# CIFAR10 Trained on Custom ResNet Model with GradCAM
This is a simple Gradio interface that allows you to perform inference on a CIFAR10 dataset trained on a Custom ResNet model and visualize the GradCAM results. GradCAM (Gradient-weighted Class Activation Mapping) is a technique that highlights the regions in an image that are important for the model's prediction.
## How to Use the Interface
1. Upload an image by clicking on the "Choose File" button. The image should have dimensions of 32x32 pixels.
2. **Show GradCAM Images**: Select this checkbox to visualize the GradCAM results on the uploaded image. GradCAM highlights the regions of the image that are important for the model's prediction.
3. **Number of GradCAM Images**: Enter the number of GradCAM images you want to visualize. This option is only effective when "Show GradCAM Images" is selected.
4. **Which Layer?**: Use the slider to choose the layer from which GradCAM will be computed. You can select from layers -3, -2, or -1. This option is only effective when "Show GradCAM Images" is selected.
5. **Opacity of GradCAM**: Use the slider to adjust the opacity of the GradCAM overlay on the image. This option is only effective when "Show GradCAM Images" is selected.
6. **Show Misclassified Images**: Select this checkbox to visualize a gallery of misclassified images. These images are randomly chosen from a folder of misclassified images.
7. **Number of Misclassified Images (max 10)**: Enter the number of misclassified images you want to visualize. This option is only effective when "Show Misclassified Images" is selected.
8. **Number of Top Classes (max 10)**: Enter the number of top classes to display along with their confidence scores.
9. Click the "Submit" button to perform inference and visualize the results.
## Output
1. **Top Classes**: The interface will display the top classes along with their confidence scores for the uploaded image.
2. **Output Image**: The interface will show the GradCAM result overlayed on the uploaded image. This image highlights the important regions that the model used for its prediction. If "Show GradCAM Images" is not selected, the original uploaded image will be shown.
3. **Misclassified Images**: If "Show Misclassified Images" is selected, the interface will display a gallery of misclassified images. These images are randomly chosen from a folder of misclassified images.
## Examples
The interface provides some example images along with pre-selected settings. Feel free to modify the settings or upload your own images to visualize the GradCAM results on different images.
Please note that the provided model is pre-trained and loaded from a checkpoint file. You can adjust the model and GradCAM settings in the code to experiment with different configurations.