andreysher
commited on
Commit
•
513aed0
1
Parent(s):
d2d52b7
Add README and mac measuring
Browse files
README.md
CHANGED
@@ -1,3 +1,43 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- coco
|
5 |
+
pipeline_tag: image-segmentation
|
6 |
+
tags:
|
7 |
+
- computer-vision
|
8 |
+
- image-segmentation
|
9 |
+
- ENOT-AutoDL
|
10 |
---
|
11 |
+
|
12 |
+
# ENOT-AutoDL pruning benchmark on MS-COCO
|
13 |
+
|
14 |
+
This repository contains models accelerated with [ENOT-AutoDL](https://pypi.org/project/enot-autodl/) framework.
|
15 |
+
Models from [Torchvision](https://pytorch.org/vision/stable/models.html) are used as a baseline.
|
16 |
+
Evaluation code is also based on Torchvision references.
|
17 |
+
|
18 |
+
## DeeplabV3_MobileNetV3_Large
|
19 |
+
|
20 |
+
| Model | Latency (MMACs) | mean IoU (%) |
|
21 |
+
|---------------------------------------------|:---------------:|:------------:|
|
22 |
+
| **DeeplabV3_MobileNetV3_Large Torchvision** | 8872.87 | 47.0 |
|
23 |
+
| **DeeplabV3_MobileNetV3_Large ENOT (x2)** | 4436.41 (x2.0) | 47.6 (+0.6) |
|
24 |
+
| **DeeplabV3_MobileNetV3_Large ENOT (x4)** | 2217.53 (x4.0) | 46.4 (-0.6) |
|
25 |
+
|
26 |
+
# Validation
|
27 |
+
|
28 |
+
To validate results, follow this steps:
|
29 |
+
|
30 |
+
1. Install all required packages:
|
31 |
+
```bash
|
32 |
+
pip install -r requrements.txt
|
33 |
+
```
|
34 |
+
1. Calculate model latency:
|
35 |
+
```bash
|
36 |
+
python measure_mac.py --model-path path/to/model.pth
|
37 |
+
```
|
38 |
+
1. Measure mean IoU of PyTorch (.pth) model:
|
39 |
+
```bash
|
40 |
+
python test.py --data-path path/to/imagenet --model-path path/to/model.pth
|
41 |
+
```
|
42 |
+
|
43 |
+
If you want to book a demo, please contact us: [email protected] .
|
common.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
import os
|
|
|
2 |
|
3 |
import torch
|
4 |
import torchvision
|
5 |
from fvcore.nn import FlopCountAnalysis
|
6 |
from torch import nn
|
7 |
-
from transforms import Compose
|
8 |
|
9 |
sys.path.append("vision/references/segmentation")
|
|
|
10 |
from coco_utils import ConvertCocoPolysToMask
|
11 |
from coco_utils import FilterAndRemapCocoCategories
|
12 |
from coco_utils import _coco_remove_images_without_annotations
|
|
|
1 |
import os
|
2 |
+
import sys
|
3 |
|
4 |
import torch
|
5 |
import torchvision
|
6 |
from fvcore.nn import FlopCountAnalysis
|
7 |
from torch import nn
|
|
|
8 |
|
9 |
sys.path.append("vision/references/segmentation")
|
10 |
+
from transforms import Compose
|
11 |
from coco_utils import ConvertCocoPolysToMask
|
12 |
from coco_utils import FilterAndRemapCocoCategories
|
13 |
from coco_utils import _coco_remove_images_without_annotations
|
measure_mac.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import torch
|
3 |
+
|
4 |
+
from common import flops_calculation_function
|
5 |
+
|
6 |
+
if __name__ == '__main__':
|
7 |
+
parser = argparse.ArgumentParser()
|
8 |
+
parser.add_argument(
|
9 |
+
"--model-path",
|
10 |
+
type=str,
|
11 |
+
help="Path to models checkpoint (.pth file).",
|
12 |
+
)
|
13 |
+
args = parser.parse_args()
|
14 |
+
|
15 |
+
checkpoint = torch.load(args.model_path, map_location="cpu")
|
16 |
+
model = checkpoint["model"]
|
17 |
+
|
18 |
+
flops = flops_calculation_function(model, torch.ones(1, 3, 480, 480))
|
19 |
+
|
20 |
+
print(f"MMACs = {flops}")
|
test.py
CHANGED
@@ -38,16 +38,12 @@ def get_dataset(args: Namespace, is_train: bool, transform: Callable = None) ->
|
|
38 |
p, ds_fn, num_classes = paths["coco_orig"]
|
39 |
|
40 |
if transform is None:
|
41 |
-
transform =
|
42 |
image_set = "train" if is_train else "val"
|
43 |
ds = ds_fn(p, image_set=image_set, transforms=transform, use_v2=args.use_v2)
|
44 |
return ds, num_classes
|
45 |
|
46 |
|
47 |
-
def get_transform(is_train: bool, args: Namespace) -> Callable:
|
48 |
-
return presets.SegmentationPresetEval(base_size=520, backend=args.backend, use_v2=args.use_v2)
|
49 |
-
|
50 |
-
|
51 |
def criterion(inputs: Dict[str, torch.Tensor], target: Dict[str, torch.Tensor]) -> torch.Tensor:
|
52 |
losses = {}
|
53 |
for name, x in inputs.items():
|
|
|
38 |
p, ds_fn, num_classes = paths["coco_orig"]
|
39 |
|
40 |
if transform is None:
|
41 |
+
transform = presets.SegmentationPresetEval(base_size=520, backend=args.backend, use_v2=args.use_v2)
|
42 |
image_set = "train" if is_train else "val"
|
43 |
ds = ds_fn(p, image_set=image_set, transforms=transform, use_v2=args.use_v2)
|
44 |
return ds, num_classes
|
45 |
|
46 |
|
|
|
|
|
|
|
|
|
47 |
def criterion(inputs: Dict[str, torch.Tensor], target: Dict[str, torch.Tensor]) -> torch.Tensor:
|
48 |
losses = {}
|
49 |
for name, x in inputs.items():
|