You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Mlint formatting updates and added default README
No technical content was changed or added
* Rename files for easier handling
Removed whitespace from tutorial makrdown filenames
Create LICENSE file instead of linking to external license
Added default READMEs for each directory
Changed image links from hard coded to relative
Removed whitespace from tutorial markdown filenames
* Update Pytorch_Data_Load.md
fixed relative link
* Remove incomplete sagemaker tutorial
This documentation is about installing AWS tools and configuring AWS environment to download LADI dataset and load dataset in Python locally and remotely.
3
+
Tutorial for the Low Altitude Disaster Imagery (LADI) dataset. This tutorial was originally forked from a [Penn State Learning Factory](https://www.lf.psu.edu/) capstone project
4
+
5
+
-[Tutorials Guide](#tutorials-guide)
6
+
-[Getting Started](#getting-started)
7
+
-[Clean and Validate LADI Dataset](#clean-and-validate-ladi-dataset)
8
+
-[PyTorch Data Loading](#pytorch-data-loading)
9
+
-[Train and Test A Classifier](#train-and-test-a-classifier)
This folder contains dataset with 2000 images and labels.
17
+
This documentation is about installing AWS tools and configuring AWS environment to download LADI dataset and load dataset in Python locally and remotely.
19
18
20
19
## Clean and Validate LADI Dataset
21
-
[Clean and Validate LADI Dataset](https://github.com/NaeRong/DS440_Capstone/blob/master/Tutorials/Clean%20and%20Validate%20LADI%20Dataset.md)
20
+
21
+
[Clean and Validate LADI Dataset](./Tutorials/Clean_Validate.md)
22
22
23
23
This documentation is about clean the LADI dataset. For this project, we have only extracted 2000 images for training.
24
24
25
25
## PyTorch Data Loading
26
-
[PyTorch Data Loading](https://github.com/NaeRong/DS440_Capstone/blob/master/Tutorials/Pytorch%20Data%20Load.md)
26
+
27
+
[PyTorch Data Loading](./Tutorials/Pytorch_Data_Load.md)
27
28
28
29
This documentation is about loading LADI dataset in PyTorch framework including examples of writing custom `Dataset`, `Transforms` and `Dataloader`.
29
30
30
31
## Train and Test A Classifier
31
-
[Train and Test A Classifier](https://github.com/NaeRong/DS440_Capstone/blob/master/Tutorials/Train%20and%20Test%20A%20Classifier.md)
32
+
33
+
[Train and Test A Classifier](./Tutorials/Train_Test_Classifier.md)
32
34
33
35
This documentation is about training and testing a classifier model using Convolutional Neural Network (CNN) from scratch.
Pytorch provides cnn_finetune, which includes multiple deep learning models, pre-trained on the ImageNet dataset. The package automatically replaces classifier on top of the network, which allows the user to train a network with a dataset that has a different number of classes.
6
-
Also, cnn_finetune allows users to add a dropout layer or a custom pooling layer.
22
+
Pytorch provides `cnn_finetune`, which includes multiple deep learning models, pre-trained on the ImageNet dataset. The package automatically replaces classifier on top of the network, which allows the user to train a network with a dataset that has a different number of classes.
23
+
Also, `cnn_finetune` allows users to add a dropout layer or a custom pooling layer.
7
24
8
-
In this project, we are focusing on ResNet and AlexNet
@@ -39,6 +57,7 @@ MobileNets are based on a streamlined architecture that uses depth-wise separabl
39
57
```python
40
58
model = make_model('mobilenet', num_classes=2, pretrained=True)
41
59
```
60
+
42
61
## Define Image Transforms
43
62
44
63
Having a large dataset is crucial for the performance of the deep learning model. However, we can improve the performance of the model by augmenting the data we already have.
This section defines all the model parameters. Users can reference the parameter by calling args.{argument}.
60
-
For this project, we have defined batch-size / number of epochs / learning rate / momentum / use of Cuda / model name. All the parameters are subject to change and add depends on the user preference.
80
+
For this project, we have defined batch-size / number of epochs / learning rate / momentum / use of Cuda / model name. All the parameters are subject to change and add depends on the user preference.
Users can use "to.device" to switch the training from using cpu to gpu.
100
+
79
101
```python
80
102
args = parser.parse_args()
81
103
use_cuda =not args.no_cuda and torch.cuda.is_available()
@@ -87,6 +109,7 @@ Users can change the `default` argument for `--model-name` to use various pretra
87
109
For a full list of all pretrained model, users can visit [PyTorch Image Classification Models](https://pytorch.org/docs/stable/torchvision/models.html).
88
110
89
111
## Train model
112
+
90
113
The train function handles the training and validation of a given model. As input, it takes a PyTorch model, a dictionary of dataloaders, a loss function, an optimizer, and a specified number of epochs to train and validate for. The train function also print loss values for every 20 mini-batches.
print('Accuracy of the network on the 200 test images: %d%%'% (
147
172
100* correct / total))
148
173
```
174
+
149
175
## Run Training and Testing Step
176
+
150
177
Finally, the last step is to setup the loss for the model, then run the training and testing function for the set number of epochs.
151
178
In this step, we also create an optimizer that only updates the desired parameters. To construct an Optimizer you have to give it an iterable containing the parameters (all should be Variable s) to optimize. Then, you can specify optimizer-specific options such as the learning rate, weight decay, etc.
152
179
The common optimizer includes:
@@ -176,18 +203,21 @@ for epoch in range(1, args.epochs):
176
203
train(model, epoch, optimizer, train_loader)
177
204
test(model, test_loader)
178
205
```
206
+
179
207
## Saving and loading models for parameter tuning
180
208
181
-
In PyTorch, the user can save the trained model into a .pt or .pth file extension. In this case, we are saving the resnet50 model as "resnet50_2_58.pth". By referencing the path, PyTorch will load the model's parameter. Users can define a new set of model parameters before this step.
209
+
In PyTorch, the user can save the trained model into a .pt or .pth file extension. In this case, we are saving the resnet50 model as "resnet50_2_58.pth". By referencing the path, PyTorch will load the model's parameter. Users can define a new set of model parameters before this step.
182
210
183
-
In this step, we used the existing model to predict the new dataset.
211
+
In this step, we used the existing model to predict the new dataset.
184
212
185
213
Parameter Tuning Example: (define new parameter using "parser.add_argument" function)
186
-
* Change the number of epochs from 30 to 50
187
-
* Change the batch size from 4 to 16
188
-
* Change the learing rate from 0.1 to 0.01
214
+
215
+
- Change the number of epochs from 30 to 50
216
+
- Change the batch size from 4 to 16
217
+
- Change the learing rate from 0.1 to 0.01
189
218
190
219
### ResNet / DenseNet / MobileNet
220
+
191
221
```python
192
222
model_name ='resnet50_2_58.pth'
193
223
PATH=f"/content/drive/My Drive/{model_name}"
@@ -214,7 +244,9 @@ for epoch in range(0, args.epochs):
214
244
train(model, epoch, optimizer, train_loader)
215
245
test(model, test_loader)
216
246
```
247
+
217
248
### AlexNet
249
+
218
250
```python
219
251
model = make_model(
220
252
model_name,
@@ -223,6 +255,7 @@ model = make_model(
223
255
input_size= (256,256),
224
256
)
225
257
```
258
+
226
259
## Load saved models to predict image labels
227
260
228
261
In this step, we are using the existing model to predict the new dataset. As the result, we can observe the label prediction on 8 images.
The accuracy and size for each model is shown in the table. Our ResNet 101 model can achieve the best accuracy of 79%. Our MobileNet V2 has a very small model size of 17 MB compared to other models, so it has the potential to be deployed on a hardware device.
313
+

285
314
286
-
In terms of future improvement, we are looking into fine-tuning the MobilNetV2 and ResNet 101 models with more images.
315
+
## Model Accuracy
287
316
317
+
The accuracy and size for each model is shown in the table. Our ResNet 101 model can achieve the best accuracy of 79%. Our MobileNet V2 has a very small model size of 17 MB compared to other models, so it has the potential to be deployed on a hardware device.
288
318
319
+
In terms of future improvement, we are looking into fine-tuning the MobilNetV2 and ResNet 101 models with more images.
0 commit comments