Closed ltnghia closed 5 years ago
Maybe @zimenglan-sysu-512 can help here given that he implemented GroupNorm?
hi @ltnghia
if u want to convert Group Norm
in the imagenet pretrained model from Detectron, u can see these lines.
btw, i don't have a try to convert GN in the coco-trained model from Detectron.
Great thanks to @zimenglan-sysu-512
hi @ltnghia
u can use load_c2_pkl_weights
to see the keys of trained model (pkl file) from detectron:
def load_c2_pkl_weights(file_path):
with open(file_path, "rb") as f:
if torch._six.PY3:
data = pickle.load(f, encoding="latin1")
else:
data = pickle.load(f)
if "blobs" in data:
weights = data["blobs"]
else:
weights = data
return weights
and then map these key to maskrcnn-benchmark
manually:
def see_and_map_keys(weights):
fpns = []
for k in weights.keys():
if k.find("fpn") is not -1:
fpns.append(k)
rpns = []
for k in weights.keys():
if k.find("rpn") is not -1:
rpns.append(k)
roi_heads = []
for k in weights.keys():
if k.find("head") is not -1 or k.find("pred") is not -1:
roi_heads.append(k)
masks = []
for k in weights.keys():
if k.find("mask") is not -1 or k.find("logits") is not -1:
masks.append(k)
# map the keys here
......
@zimenglan-sysu-512: Thank you for your help.
@ltnghia if you manage to make the conversion work, a PR adding support for it would be great!
❓ Questions and Help
I tried to convert Group Norm models from Detectron to Maskrcnn-Benchmark, but structure of them are so different in FPN, roi_heads. How can we load GN-Detectron models?