Comments (10)
I have a same question too.
from defrcn.
In fact, there are no special considerations for this design. I believe that whether to use FPN does not affect the performance improvement of the proposed method, but it may affect the performance upper bound.
I have not done more experiments on FPN features, if you have some interesting conclusions, please let me know.
from defrcn.
dear author, hi, I have tried to implement the FPN config using gdlayer
.
Here is my core code:
# init
# fpn setting
self.affine_rpn_dict = {}
self.affine_rcnn_dict = {}
for k in backbone.output_shape().keys(): # [p2, p3, p4, p5, p6]
self.affine_rpn_dict[k] = AffineLayer(num_channels=backbone.output_shape()[k].channels, bias=True)
self.affine_rcnn_dict[k] = AffineLayer(num_channels=backbone.output_shape()[k].channels, bias=True)
# forward
features_de_rpn = {k: self.affine_rpn_dict[k](decouple_layer(features[k], self.rpn_backward_scale)) for k in features}
features_de_rcnn = {k: self.affine_rcnn_dict[k](decouple_layer(features[k], self.roi_heads_backward_scale)) for k in features}
However, there is a cuda-cpu-mismatch error in gdl.py
.
class AffineLayer(nn.Module):
def __init__(self, num_channels, bias=False):
super(AffineLayer, self).__init__()
weight = torch.FloatTensor(1, num_channels, 1, 1).fill_(1)
self.weight = nn.Parameter(weight, requires_grad=True)
self.bias = None
if bias:
bias = torch.FloatTensor(1, num_channels, 1, 1).fill_(0)
self.bias = nn.Parameter(bias, requires_grad=True)
def forward(self, X):
# out = X * self.weight.expand_as(X)
out = X * self.weight.expand_as(X).cuda() # if not .cuda(), X is on cuda(), while self.weight is on cpu().
if self.bias is not None:
out = out + self.bias.expand_as(X).cuda() # if not .cuda(), X is on cuda(), while self.biasis on cpu().
return out
When I add .cuda()
, the code can execute.
However, I found that the training time became much slower about 5 times.
from defrcn.
This issue has been solved by putting weight
and bias
to 'cuda'
so that it became much faster.
I am sorry for my poor previous code.
Thanks.
class AffineLayer(nn.Module):
def __init__(self, num_channels, bias=False):
super(AffineLayer, self).__init__()
weight = torch.FloatTensor(1, num_channels, 1, 1).fill_(1).to('cuda')
self.weight = nn.Parameter(weight, requires_grad=True).to('cuda)
self.bias = None
if bias:
bias = torch.FloatTensor(1, num_channels, 1, 1).fill_(0)
self.bias = nn.Parameter(bias, requires_grad=True)
def forward(self, X):
# out = X * self.weight.expand_as(X)
out = X * self.weight.expand_as(X)
if self.bias is not None:
out = out + self.bias.expand_as(X)
return out
from defrcn.
@Wei-i Hi, have you got an improvement with FPN? I'm curious about this, thank you!
from defrcn.
@chenf99 I have tried to add more affine layers. But there is no significant improvement.
from defrcn.
@Wei-i How is your network performance? Is it works?
from defrcn.
I tried R101-FPN with either one shared affine layer or 5 independent affine layers each for ['p2', 'p3', 'p4', 'p5', 'p6'] of FPN respectively. I also remove the additional cls_head and use the original box_head. All other settings remain the same as R101-C4. However, the results drop a lot, e.g., from 66.21 to 55.29 (voc split1 10shot). Anybody encountered a similar issue?
from defrcn.
This issue has been solved by putting
weight
andbias
to'cuda'
so that it became much faster. I am sorry for my poor previous code. Thanks.class AffineLayer(nn.Module): def __init__(self, num_channels, bias=False): super(AffineLayer, self).__init__() weight = torch.FloatTensor(1, num_channels, 1, 1).fill_(1).to('cuda') self.weight = nn.Parameter(weight, requires_grad=True).to('cuda) self.bias = None if bias: bias = torch.FloatTensor(1, num_channels, 1, 1).fill_(0) self.bias = nn.Parameter(bias, requires_grad=True) def forward(self, X): # out = X * self.weight.expand_as(X) out = X * self.weight.expand_as(X) if self.bias is not None: out = out + self.bias.expand_as(X) return out
I have tried with similar implementation with yours. It seems that there is no need to explicitly put the weights to cuda, as the whole model will be moved to cuda device finally with self.to(self.device)
. I notice significant performance drop with FPN. Do you have the similar issue?
from defrcn.
from defrcn.
Related Issues (20)
- How can I customize new hyperparameters in detectron2
- argument 'alpha' must be Number, not NoneType HOT 2
- 可视化
- AssertionError: Checkpoint checkpoints/voc/mydefrcn/defrcn_det_r101_base1/model_reset_remove.pth not found! HOT 6
- Why the different number of images on inference?
- How to reproduce the results in Figure4(b)? HOT 1
- Help with multi-GPU training in Google Colab HOT 1
- Guide on Fine Tuning
- TypeError: init() got an unexpected keyword argument 'first_stride' HOT 2
- Where is pascal VOC metasplit located?
- Out of memory error during evaluation but training works fine! HOT 3
- running Inference on model
- Why final checkpoint is removed in run_voc.sh script? HOT 1
- Do we need to give support image during inference? HOT 1
- cuda version HOT 2
- About the fine tune problems
- main.py: error: unrecognized arguments: --opts MODEL.WEIGHTS /public/home/jd_fky/project/DeFRCN/data/ImageNetPretrained/MSRA/R-101.pkl OUTPUT_DIR checkpoints/coco/defrcn/defrcn_det_r101_base 3 I don't know why running main.py causes this problem HOT 1
- fine-tuning on my cutsomized dataset
- OutOfMemoryError with PrototypicalCalibrationBlock HOT 5
- RuntimeError: CUDA error: no kernel image is available for execution on the device
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from defrcn.