junsukchoe / ADL

Attention-based Dropout Layer for Weakly Supervised Object Localization (CVPR 2019 Oral)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Predictions?

batrlatom opened this issue · comments

Hi.
Would you share a code for making predictions easily ( TF )?

Hi,

Could you give me some more information?

I already trained the network on CUB dataset. Now I would like to make predictions for my own images. Easily load weights, load one image, make prediction on this one image and print bounding box(es). The code for making prediction is in "cam" function as I get it. You are making predictions for testing purposes on the whole dataset. Is there any quick function how to make bboxes just for one image? Is using something like

   model_file = "train_log/shop_dataset/model-50.index"
   pred_config = PredictConfig(
        model=model,
        session_init=get_model_loader(model_file),
        input_names=['input', 'label'],
        output_names=
            ['actmap', 'grad'],
        return_input=True
    )
    pred = OfflinePredictor(pred_config)
    batch_image = np.random.rand(1, 224, 224, 3)
    b = pred(batch_image, [0])
    print("*********************************************************************")
    inp, outp = b
    image, label = inp
    convmaps, W = outp
    NUMBER,CHANNEL,HEIGHT,WIDTH = np.shape(convmaps)
    print(NUMBER,CHANNEL,HEIGHT,WIDTH)
    # generating heatmap
    weight = W[0]   # c x 1
    print("weight: ", weight.shape)
    convmap = convmaps[0,:, :, :]  # c x h x w
    print("convmap: ", convmap.shape)
    mergedmap = np.matmul(weight, convmap)
    mergedmap = cv2.resize(mergedmap,(224,224))
    print(mergedmap.shape)

The right way to go?

and second question ... Do you have a code for integration with Mobilenet_v1? As you mentioned it in the
paper.. Thanks,

T

Sorry for the late reply.

  1. Unfortunately, there is no prediction module for only one image in current version.
  2. We will release MobileNet V1 code, but it should be cleaned up.. But we are pretty busy nowadays so it may be delayed.

Do not worry, I already figured it out using PyTorch. The Mobilenet version would be great. Thank you for the code, it works great!