Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aman5319/multi-label
Pytorch code for multi-Instance multi-label problem
https://github.com/aman5319/multi-label
classify-images f1score lrfinder multilabel-multiclass onecyclepolicy pytorch
Last synced: 29 days ago
JSON representation
Pytorch code for multi-Instance multi-label problem
- Host: GitHub
- URL: https://github.com/aman5319/multi-label
- Owner: aman5319
- Created: 2019-03-08T12:26:16.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-08T12:32:18.000Z (almost 6 years ago)
- Last Synced: 2023-03-08T12:40:49.262Z (almost 2 years ago)
- Topics: classify-images, f1score, lrfinder, multilabel-multiclass, onecyclepolicy, pytorch
- Language: Jupyter Notebook
- Size: 24.1 MB
- Stars: 52
- Watchers: 2
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## pytorch Classify Scene Images (Multi-Instance Multi-Label problem)
The objective of this study is to develop a deep learning model that
will identify the natural scenes from images. This type of problem comes
under multi label image classification where an instance can be
classified into multiple classes among the predefined classes.## Dataset
The Complete dataset description can be found on http://lamda.nju.edu.cn/data_MIMLimage.ashx
The processed data is their in the repo [Image_data.zip](./image_scene_data.zip)
## Data Description
The image data set consists of 2,000 natural scene images, where a set of labels is artificially assigned to each image. The number of images belonging to more than one class (e.g. *sea+sunset*). On average, each image is associated with 1.24 class labels.
The `labels.json` file contains the labels in the form of list [1 -1 -1 1 -1], it means that the i-th image belongs to the 1st and 4th classes but do not belong to the 2nd, 3rd and 5th classes. The following is the order of classes **desert, mountains, sea, sunset, trees**
## Table of Content
1. Download Data
2. Structure the data
3. Visulaize the data
1. Data distribution
2. Correlation between different classes
3. Visualize images
4. Create Data pipeline
5. Model Definition (RESNET50)
6. Optimizer(Adam) and Criterion (nn.BCEWithLogitsLoss)
7. Training
8. Saving & Loading model
9. Model Finetuning
1. LrFinder and One Cycle Policy
2. unfreeze 60 % architecture and retrain
3. unfreeze 70% model and retrain10 . Visualizing some end result
## Metric Used
1. Precision Score
2. F1 scoreNote:- Refer sklearn doc for deeper understanding of the metric
# Training
As this is multi label image classification, the loss function was binary crossentropy logit and activation function used was sigmoid at the output layer. so after training there is one probabilistic threshold method which find out the best threshold value for each label seperately and based on the threshold value(0.5)
```python
preds = torch.sigmoid(output).data > 0.5
preds = preds.to(torch.float32)
```## Final Result
F1 score| Loss
----------|-----------
88.85%|0.1962