trashdetect_engine
Project description
PyTorch-MaskRCNN
A PyTorch implementation of simple Mask R-CNN.
This repository is a toy example of Mask R-CNN with two features:
- It is pure python code and can be run immediately using PyTorch 1.5.1 and trochvision 0.8.2,
- Simplified construction and easy to understand how the model works based on tutorial.
The code is based largely on TorchVision.
Requirements
- Windows or Linux, with Python ≥ 3.7
- PyTorch ≥ 1.5.0
- matplotlib - visualizing images and results
- pycocotools - for COCO dataset and evaluation; Windows version is here
Neptune
To track logs (for example training loss) we used neptune.ai. If you are interested in logging your experiments there, you should create account on the platform and create new project. Then:
- Find and set Neptune API token on your system as environment variable (your NEPTUNE_API_TOKEN should be added to ~./bashrc)
- Add your project_qualified_name name in the
train.py
neptune.init(project_qualified_name = 'YOUR_PROJECT_NAME/detect-waste')
Currently it is set to private detect-waste neptune space. - install neptun-client library
pip install neptune-client
To run experiments with neptune simply add --neptune
flag during launch train.py
.
For more check LINK.
Datasets
This repository supports detect-waste datasets (usualy COCO based annotations) with two class - 'litter' and 'background'.
We expect the directory structure to be the following:
path/to/repository/
annotations/ # annotation json files
path/to/images/ # all images
You can modify datasets/data.py
script to add new dataset and another format of paths for coco annotations type.
Check detect-waste/annotations/README.md
to verify provided annotations by Detect Waste in Pomerania team.
Training
Simply run:
python3 train.py --num_epochs 26 --gpu_id 2 --output_dir /path/to/save/checkpoints --images_dir /path/to/images
or modify the parameters in run.sh
, and run:
bash ./run.sh
Note: This is a simple model and only supports one gpu (not distribiuted training).
Evaluation
Simply run on cuda:2:
python train.py --gpu_id 2 --images_dir /path/to/images --resume /path/to/checkpoint.pth --test-only
or modify the parameters in notebooks/eval.ipynb
to visualize predictions of the model.
Performance
The model utilizes part of TorchVision's weights, which is pretrained on COCO dataset. Test on Multi detect-waste Segmentation val, on 1 RTX 2080Ti GPU:
model | backbone | dataset | bbox AP@0.5 | bbox AP@0.5:0.95 | mask AP@0.5 | mask AP@0.5:0.95 |
---|---|---|---|---|---|---|
Mask R-CNN | ResNet 50 | Multi | 27.95 | 16.49 | 23.05 | 12.94 |
Mask R-CNN | ResNetXt 101* |
Multi | 19.70 | 6.20 | 24.70 | 13.20 |
*
results achived using mmdetection framework.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file trashdetect_engine-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: trashdetect_engine-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7077931c377c97913cf0850356dddf176708df38faf889ebc7a9f1650056f68d |
|
MD5 | 32a1b38603a1e7d7aeec4a7ab383f1cb |
|
BLAKE2b-256 | b2cd9bffa1b356ebf051b16457236a58d46b95e9bf31b400667cae4f694ce636 |