Skip to content

Commit

Permalink
removed Mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Apr 21, 2022
1 parent 5884822 commit 9f04a0f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 26 deletions.
2 changes: 0 additions & 2 deletions deploy/quant_fx/fx_ptq_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ def export_quant_torchscript(model):
operator_export_type=OperatorExportTypes.ONNX_ATEN_FALLBACK,
)
print("int8 onnx saved.")

evaluate_model(dm, test_loader)


Expand All @@ -287,7 +286,6 @@ def export_quant_torchscript(model):
model.load_state_dict(torch.load("r18_raw.pth", map_location="cpu"))
else:
from alfred.dl.torch.common import device

train_model(model, train_loader, test_loader, device)
print("train finished.")
torch.save(model.state_dict(), "r18_raw.pth")
Expand Down
2 changes: 0 additions & 2 deletions export_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import time
import cv2
from numpy.core.fromnumeric import sort
import tqdm
import torch
import time
Expand All @@ -23,7 +22,6 @@
from yolov7.config import add_yolo_config
import onnx_graphsurgeon as gs
import onnx

from alfred.vis.image.mask import label2color_mask, vis_bitmasks
from alfred.vis.image.det import visualize_det_cv2_part, visualize_det_cv2_fancy
from alfred.dl.torch.common import device
Expand Down
30 changes: 9 additions & 21 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ Make sure you have read **rules** before ask me any questions.
```
python export_onnx.py --config-file configs/coco/sparseinst/sparse_inst_r50_giam_aug.yaml --video-input ~/Videos/a.flv --opts MODEL.WEIGHTS weights/sparse_inst_r50_giam_aug_2b7d68.pth INPUT.MIN_SIZE_TEST 512
```
If you are on a CPU device, please using:
```
python export_onnx.py --config-file configs/coco/sparseinst/sparse_inst_r50_giam_aug.yaml --input images/COCO_val2014_000000002153.jpg --verbose --opts MODEL.WEIGHTS weights/sparse_inst_r50_giam_aug_2b7d68.pth MODEL.DEVICE 'cpu'
```
Then you can have `weights/sparse_inst_r50_giam_aug_2b7d68_sim.onnx` generated, this onnx can be inference using ORT without any unsupported ops.


Expand Down Expand Up @@ -255,28 +259,12 @@ tbd.

## 🀄️ Some Exp Visualizations

1. GridMask

![](https://z3.ax1x.com/2021/06/27/RYeJkd.png)
![](https://z3.ax1x.com/2021/07/06/Roj5dg.png)

Our GridMask augmentation also supports 2 modes.



2. Mosaic

![](https://z3.ax1x.com/2021/07/06/RIX1iR.png)
![](https://z3.ax1x.com/2021/07/06/Roq97d.png)

Our Mosaic support any size and any any image numbers!

**new**:
we merged another mosiac implementation from YOLOX, this version will do random pespective:

![](https://z3.ax1x.com/2021/08/06/futTte.png)
![](https://z3.ax1x.com/2021/08/06/futv0f.png)
![](https://z3.ax1x.com/2021/08/07/fKEPvd.png)
| GridMask | Mosaic |
:-------------------------:|:-------------------------:
![](https://z3.ax1x.com/2021/06/27/RYeJkd.png) | ![](https://z3.ax1x.com/2021/07/06/RIX1iR.png)
![](https://z3.ax1x.com/2021/07/06/Roj5dg.png) | ![](https://z3.ax1x.com/2021/07/06/Roq97d.png)
![](https://z3.ax1x.com/2021/08/06/futTte.png) | ![](https://z3.ax1x.com/2021/08/06/futv0f.png)



Expand Down
3 changes: 2 additions & 1 deletion yolov7/modeling/transcoders/decoder_sparseinst.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ def forward(self, features):
normalizer = iam_prob.sum(-1).clamp(min=1e-6)
inst_features = inst_features / normalizer[:, :, None]

d4 = torch.div(N, 4, rounding_mode='floor')
# d4 = torch.div(N, 4, rounding_mode='floor') # can't use this for onnx tracable
d4 = N // 4
inst_features = (
inst_features.reshape(B, 4, d4, -1)
.transpose(1, 2)
Expand Down

0 comments on commit 9f04a0f

Please sign in to comment.