File size: 3,642 Bytes
fb36c8a
 
 
 
 
 
863c556
fb36c8a
863c556
 
 
 
 
 
fb36c8a
 
 
 
2c60880
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
title: Cifar10
emoji: 🔥
colorFrom: purple
colorTo: indigo
sdk: gradio
sdk_version: 4.38.1
app_file: app.py
fullWidth: true
models:
- >-
  https://huggingface.co/spaces/Shilpaj/cifar10/blob/main/epoch%3D23-step%3D2112.ckpt
datasets:
- CIFAR10
pinned: false
license: mit
---



# Model Trained for CIFAR10

- This Application demonstrate the inference side of the model trained on the CIFAR dataset
- David C's model architecture is recreated and trained on CIFAR10 dataset to achieve the accuracy of 90+% within 24 epochs
- Once Cycle Policy is used to speed up the training process
- The model is coded using PyTorch Lightning. Mentioned below is the link for Training Repository where you can check the code for model training and tracked metrics

##### 				[Training Repo Link](https://github.com/Shilpaj1994/ERA/tree/master/Session12)

- After the Training, model checkpoint is stored on the system and uploaded to Gradio Spaces. Attached below is the link to download model file

  ##### [Download Model File](https://huggingface.co/spaces/Shilpaj/cifar10/resolve/main/epoch%3D23-step%3D2112.ckpt)

-  This app has four features in four tabs:

  - **GradCam:** 
    - To visualize which portion of the image model is actually looking at while inferencing on the image
    - Using this, we can come up with an augmentation strategy that can improve the model accuracy
  - **Misclassified Image:**
    - While training the model, though the `test accuracy` was 90+%, there were still 10% images which were misclassified
    - The feature helps to visualize those images with their respective correct and incorrect labels
    - This can be used to come up with a strategy to improve accuracy for a particular class
  - **Feature Map Visualization:**
    - There are 6 block in this model
    - Each block has 2 or 3 convolutional layers
    - The output of specific kernel are visualized for first convolutional layer of all 6 blocks
  - **Kernel Visualization:**
    - In the first layer of each of the six blocks, there are kernels which are creating the feature maps
    - Some of those kernels are visualized in this section



**Dependencies:**

- Python Version: 3.x
- PyTorch Lightning: 2.0.6



## Usage:

### GradCam

- Upload an image or select from example
- Select how much percentage of original image should be overlapped on what actually model is looking at in the image
- Select the number of top classes you want to see
- Select the block number for which first convolutional layer's activation you want to see
- Click on the `Submit` button to see the results

![GradCam](https://github.com/Shilpaj1994/ERA/blob/master/Session12/Data/data/gradcam.gif?raw=true)



### Misclassified Images

- Select the number of misclassified images you want to see
- Click on `Display Misclassified Images` to show the images in the center and their respective correct and misclassified labels in the sequence

![Misclassified Images](https://github.com/Shilpaj1994/ERA/blob/master/Session12/Data/data/misclassified.gif?raw=true)



### Feature Map Visualization

- Upload an image
- Select the kernel number 
- Click on `Visualize FeatureMaps` to see the feature maps created by the kernel number for first convolutional layer in each of the six blocks

![Feature Maps](https://github.com/Shilpaj1994/ERA/blob/master/Session12/Data/data/featuremaps.gif?raw=true)



### Kernel Visualization

- Select the block number from which first convolutional layer's kernel to be visualized
- Click on `Visualize Kernels` to see the kernels

![Kernel](https://github.com/Shilpaj1994/ERA/blob/master/Session12/Data/data/kernels.gif?raw=true)