erikalu / class-agnostic-counting

63 stars 14 forks source link

could not load pretrained resnet50 #11

Open renaldfredy opened 1 month ago

renaldfredy commented 1 month ago

Hi Erika,

I got error about the shape of resnet, and could not solved it. May you help?

==> could not load pretrained resnet50 /usr/local/lib/python3.10/dist-packages/keras/src/models/functional.py:225: UserWarning: The structure of inputs doesn't match the expected structure: ['image_patch', 'image']. Received: the structure of inputs={'image': '', 'image_patch': ''} warnings.warn( Traceback (most recent call last): File "/content/drive/MyDrive/Disertasi/Class-Agnostic-Counting/class-agnostic-counting/demo.py", line 56, in inference(args) File "/content/drive/MyDrive/Disertasi/Class-Agnostic-Counting/class-agnostic-counting/demo.py", line 36, in inference pred = model.predict(data)[0, :vis_im.shape[0], :vis_im.shape[1]] File "/usr/local/lib/python3.10/dist-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler raise e.with_traceback(filtered_tb) from None File "/usr/local/lib/python3.10/dist-packages/keras/src/layers/input_spec.py", line 245, in assert_input_compatibility raise ValueError( ValueError: Exception encountered when calling Functional.call().

Input 0 of layer "resnet50_patchnet" is incompatible with the layer: expected shape=(None, 63, 63, 3), found shape=(1, 800, 800, 3)

Arguments received by Functional.call(): • inputs={'image': 'tf.Tensor(shape=(1, 800, 800, 3), dtype=float32)', 'image_patch': 'tf.Tensor(shape=(1, 63, 63, 3), dtype=float32)'} • training=False • mask={'image': 'None', 'image_patch': 'None'}

erikalu commented 1 month ago

Hi, does your input data consist of an image of size 800x800 and image patch of size 63x63?

renaldfredy commented 1 month ago

Yes, as your instruction in the description

erikalu commented 1 month ago

Is this your custom data or the example data? Are you able to run the demo successfully?

renaldfredy commented 1 month ago

This is example data from yours, and still unable to run the demo

erikalu commented 1 month ago

Hi, I wasn't able to reproduce the error using the Conda environment. What versions are you using for tensorflow, keras, etc.?

renaldfredy commented 1 month ago

I’m using google colab, so actually no need to download tensorslow and keras. However, I have check those version specifically python 3.10.12, keras 3.4.1, tensorflow 2.17.0

erikalu commented 1 month ago

The versions required are keras 2.4.3 and tensorflow 2.2.0, could you please try with those?

renaldfredy commented 1 month ago

image Okay all done properly, thank you. But it seems like hitmap_vis.jpg quiet different with your paper.

image
erikalu commented 1 month ago

heatmap_vis overlays the prediction in green on top of the input image for visualization purposes.