weiren119 commited on
Commit
c01c5f7
1 Parent(s): 979d58a

Fix: downgrade the torchversion to solve the yolov5 model inplace problem

Browse files

TODO
- Load the yolov5 model and rexport to higher version's torch with inplace setting for Harwish

requirements.txt CHANGED
@@ -6,8 +6,8 @@ PyYAML
6
  requests
7
  scipy
8
  toml
9
- torch==1.9.0
10
- torchvision==0.10.0
11
  tqdm
12
  typed-ast
13
  typing-extensions
 
6
  requests
7
  scipy
8
  toml
9
+ torch==1.6.0
10
+ torchvision==0.7.0
11
  tqdm
12
  typed-ast
13
  typing-extensions
src/digitizer/yolov5/models/common.py CHANGED
@@ -7,7 +7,7 @@ import torch.nn.functional as F
7
  from torch import Tensor
8
 
9
  # Avoid the use of original Hardswish at torch to avoid the error:
10
- class Hardswish(nn.Module):
11
  r"""Applies the hardswish function, element-wise, as described in the paper:
12
 
13
  `Searching for MobileNetV3`_.
@@ -66,7 +66,7 @@ class Conv(nn.Module):
66
  super(Conv, self).__init__()
67
  self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=False)
68
  self.bn = nn.BatchNorm2d(c2)
69
- self.act = Hardswish() if act else nn.Identity()
70
 
71
  def forward(self, x):
72
  return self.act(self.bn(self.conv(x)))
 
7
  from torch import Tensor
8
 
9
  # Avoid the use of original Hardswish at torch to avoid the error:
10
+ class HardswishReplace(nn.Module):
11
  r"""Applies the hardswish function, element-wise, as described in the paper:
12
 
13
  `Searching for MobileNetV3`_.
 
66
  super(Conv, self).__init__()
67
  self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=False)
68
  self.bn = nn.BatchNorm2d(c2)
69
+ self.act = nn.Hardswish() if act else nn.Identity()
70
 
71
  def forward(self, x):
72
  return self.act(self.bn(self.conv(x)))