I use this code, but the output I receive is for 1000 proposal boxes while I need the features of the selected boxes. How can I get them?
activation = {}
def get_activation(name):
def hook(model, input, output):
activation[name] = output.detach()
return hook
model.roi_heads.box_head.fc6.register_forward_hook(get_activation(‘fc6’))
model.eval()
FEATS = []
inputs = list_img
features = {}
preds = model(inputs)
FEATS.append(activation[‘fc6’].cpu().numpy())