Giter VIP home page Giter VIP logo

hand-cnn's Introduction

Update: PyTorch based Hand Detector

If you want to use a PyTorch based hand detector, check this respository ContactHands for our NeurIPS'20 paper on hand detection and contact estimation. Using this code, we can not only detect hands but also obtain their contact information.

Contextual Attention for Hand Detection in the Wild

This repository contains the code and datasets related to the following paper:

Contextual Attention for Hand Detection in the Wild, International Conference on Computer Vision (ICCV), 2019.

Please also see the website related to the project.

Contents

This repository contains the following:

  • A Keras implementation of the proposed attention method.
  • Code to train and evaluate the Hand-CNN. This code is based on Matterport's Keras implementation of Mask-RCNN.
  • Two large-scale annotated hand datasets, TV-Hand and COCO-Hand, containing hands in unconstrained images for training and evaluation.
  • Models trained on TV-Hand and COCO-Hand datasets.

Installation

Install the required dependecies as in requirements.txt.

Data annotation format

Create annotations in a .txt file in the follwing format:

/path/to/image/, x_min, x_max, y_min, y_max, x1, y1, x2, y2, x3, y3, y4, hand, where

  • (x1, y1), (x2, y2), (x3, y3) and (x4, y4) are the coordinates of the polygon (rotated) bounding box for a hand in the anti-clockwise order.
  • The wrist is given by the line joining (x1, y1) and (x2, y2).
  • x_min = min(x1, x2, x3, x4), x_max = max(x1, x2, x3, x4), y_min = min(y1, y2, y3, y4), y_max = max(y1, y2, y3, y4).

Folder structure

The code is organized in the following structure:

datasets/
  annotations/
    train_annotations.txt
    val_annotations.txt
    test_annotations.txt

mrcnn/
  config.py
  model.py
  parallel_model.py
  utils.py
  visualize.py
  contextual_attention.py

samples/
  hand/
    results/
    hand.py
    load_weights.py

model/
  mask_rcnn_coco.h5
  trained_weights.h5

requirements.txt
setup.cfg
setup.py
  • ./datasets/annotations/: create the annotations for the training, validation and testing data in the format as described above.
  • ./mrcnn/: this directory contains the main Mask-RCNN code. The file ./mrcnn/model.py is modified to add a new orientation branch to the Mask-RCNN to predict orientation of the hand.
  • ./mrcnn/contextual_attention.py: this file implements the proposed attention method.
  • ./samples/hand/hand.py: code for training and evaluating Hand-CNN.
  • ./model/mask_rcnn_coco.h5: pretrained Mask-RCNN weights on COCO dataset.
  • ./model/trained_weights.h5: model trained on TV-Hand and COCO-Hand data.

Models

Download the models from models and place them in ./model/.

Training

Use the following command to train Hand-CNN:

python -W ignore samples/hand/hand.py --weight coco --command train

  • --weight: If coco, starts training using the pretrained COCO weights. Additionally, /path/to/weights/ can also be speciifed to start training from other weights.

The training set to be used can be specified in train function of the file ./samples/hand/hand.py.

Detection

Use the following to run detection on images and visualize them:

python -W ignore detect.py --image_dir /path/to/folder_containing_images/

The outputs will be stored ./outputs/.

Evaluation

Use the following command to to evaluate a trained Hand-CNN:

python -W ignore samples/hand/hand.py --weight path/to/weights --command test --testset oxford

  • --weight: Path to the trained weights to be used for evaluation.

Datasets

As a part of this project we release two datasets, TV-Hand and COCO-Hand. The TV-Hand dataset contains hand annotations for 9.5K image frames extracted from the ActionThread dataset. The COCO-Hand dataset contains annotations for 25K images of the Microsoft's COCO dataset.

Some images and annotations from the TV-Hand data

Some images and annotations from the COCO-Hand data

Citation

If you use the code or datasets in this repository, please cite the following paper:

@article{Hand-CNN,
  title={Contextual Attention for Hand Detection in the Wild},
  author={Supreeth Narasimhaswamy and Zhengwei Wei and Yang Wang and Justin Zhang and Minh Hoai},
  booktitle={International Conference on Computer Vision (ICCV)},
  year={2019},
  url={https://arxiv.org/pdf/1904.04882.pdf} 
}

hand-cnn's People

Contributors

supreethn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hand-cnn's Issues

Annotation quality of TV-Hand

Hi @SupreethN
Thank you for sharing your research.
I am trying to visualize both the COCO-Hand and TV-Hand datasets. I observe that TV-Hand contains many low quality annotations (boxes, (xmin, xmax, ymin, ymax)), but you state in the paper that this dataset is manually labelled?

COCO-Hands & TV-Hands annotations out of bounds for images.

Some annotations in the datasets show numbers that are out of bounds for the given image. It's possible that the code these datasets are used with handle these cases but some other implementations might not which could lead to errors. It might be useful to change all out-of-range numbers to be the max/min size of the image.

Thanks for making these datasets public since they are very useful and well made.

oxford

where can i find the "oxford"file please
i can't find "oxford/test_dataset/test_data/images/VOC2007_1.jpg"this picture

Getting error while trying to just detect the trained model on my sample image!

this is the error I am getting when everything is installed on my PC.
Please let me know what is going wrong here.
This is the error:

(tf-gpu) C:\Users\HP\Desktop\Hand-CNN-master>python -W ignore detect.py --image_dir /images/
Using TensorFlow backend.
WARNING:tensorflow:From C:\Users\HP\Anaconda3\envs\tf-gpu\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
(None, None, None, 1024)
2020-04-24 23:52:51.501368: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2020-04-24 23:52:51.594244: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties:
name: GeForce GTX 1060 3GB major: 6 minor: 1 memoryClockRate(GHz): 1.7085
pciBusID: 0000:01:00.0
totalMemory: 3.00GiB freeMemory: 2.43GiB
2020-04-24 23:52:51.600115: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
2020-04-24 23:52:51.955197: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-04-24 23:52:51.958958: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0
2020-04-24 23:52:51.961852: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0: N
2020-04-24 23:52:51.965361: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 2116 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 3GB, pci bus id: 0000:01:00.0, compute capability: 6.1)
(None, None, None, 1024)
WARNING:tensorflow:From C:\Users\HP\Desktop\Hand-CNN-master\mrcnn\model.py:794: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
Traceback (most recent call last):
File "detect.py", line 113, in
model = load_model_custom(InferenceConfig())
File "detect.py", line 63, in load_model_custom
model.load_weights('./model/trained_model.h5', by_name=True)
File "C:\Users\HP\Desktop\Hand-CNN-master\mrcnn\model.py", line 2280, in load_weights
f = h5py.File(filepath, mode='r')
File "C:\Users\HP\Anaconda3\envs\tf-gpu\lib\site-packages\h5py_hl\files.py", line 312, in init
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File "C:\Users\HP\Anaconda3\envs\tf-gpu\lib\site-packages\h5py_hl\files.py", line 142, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py\h5f.pyx", line 78, in h5py.h5f.open
OSError: Unable to open file (unable to open file: name = './model/trained_model.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

Can it run in tensorflow 2+?

I tried run detect.py but I got error:
My environment:
windows 10
python 3.7
tensorflow 2.3

I also changed #import tensorflow as tf to

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

but nothing changed!
error:

py detect.py                                                                   2020-11-05 20:10:40.841896: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
WARNING:tensorflow:From C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\compat\v2_compat.py:96: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
(?, ?, ?, 1024)
(?, ?, ?, 1024)
WARNING:tensorflow:From C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\util\dispatch.py:201: calling crop_and_resize_v1 (from tensorflow.python.ops.image_ops_impl) with box_ind is deprecated and will be removed in a future version.
Instructions for updating:
box_ind is deprecated, use box_indices instead
Traceback (most recent call last):
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 470, in _apply_op_helper
    preferred_dtype=default_dtype)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\ops.py", line 1499, in convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1502, in _autopacking_conversion_function
    return _autopacking_helper(v, dtype, name or "packed")
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1437, in _autopacking_helper
    constant_op.constant(elem, dtype=dtype, name=str(i)))
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\constant_op.py", line 264, in constant
    allow_broadcast=True)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\constant_op.py", line 282, in _constant_impl
    allow_broadcast=allow_broadcast))
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 444, in make_tensor_proto
    raise ValueError("None values not supported.")
ValueError: None values not supported.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 484, in _apply_op_helper
    values, as_ref=input_arg.is_ref).dtype.name
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\ops.py", line 1499, in convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1502, in _autopacking_conversion_function
    return _autopacking_helper(v, dtype, name or "packed")
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1437, in _autopacking_helper
    constant_op.constant(elem, dtype=dtype, name=str(i)))
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\constant_op.py", line 264, in constant
    allow_broadcast=True)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\constant_op.py", line 282, in _constant_impl
    allow_broadcast=allow_broadcast))
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 444, in make_tensor_proto
    raise ValueError("None values not supported.")
ValueError: None values not supported.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "detect.py", line 115, in <module>
    model = load_model_custom(InferenceConfig())
  File "detect.py", line 64, in load_model_custom
    model = modellib.MaskRCNN(mode="inference", config=config, model_dir='./model')
  File "D:\Artificial Intelligence\HumanDetection_Tracking\_HandDetection\Hand-CNN-master\mrcnn\model.py", line 1984, in __init__
    self.keras_model = self.build(mode=mode, config=config)
  File "D:\Artificial Intelligence\HumanDetection_Tracking\_HandDetection\Hand-CNN-master\mrcnn\model.py", line 2200, in build
    fc_layers_size=config.FPN_CLASSIF_FC_LAYERS_SIZE)
  File "D:\Artificial Intelligence\HumanDetection_Tracking\_HandDetection\Hand-CNN-master\mrcnn\model.py", line 990, in fpn_classifier_graph
    mrcnn_bbox = KL.Reshape((s[1], num_classes, 4), name="mrcnn_bbox")(x)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\base_layer_v1.py", line 776, in __call__
    outputs = call_fn(cast_inputs, *args, **kwargs)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\layers\core.py", line 540, in call
    inputs, (array_ops.shape(inputs)[0],) + self.target_shape)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\util\dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\ops\array_ops.py", line 195, in reshape
    result = gen_array_ops.reshape(tensor, shape, name)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 8234, in reshape
    "Reshape", tensor=tensor, shape=shape, name=name)
  File "C:\Users\127051\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 488, in _apply_op_helper
    (input_name, err))
ValueError: Tried to convert 'shape' to a tensor and failed. Error: None values not supported.

Model Load error in detect.py

I downloaded the [re-trained models as per your instructions. But on executinng detect.py it fails to read the model file.

It might look that i am using an invalid path but it's not the case
Traceback (most recent call last):
File "detect.py", line 114, in
model = load_model_custom(InferenceConfig())
File "detect.py", line 63, in load_model_custom
model.load_weights('./model/trained_model.h5', by_name=True)
File "/Users/muazmaqbool/Downloads/Hand-CNN-master/mrcnn/model.py", line 2282, in load_weights
f = h5py.File(filepath, mode='r')
File "/Users/muazmaqbool/anaconda3/envs/soccer/lib/python3.7/site-packages/h5py/_hl/files.py", line 394, in init
swmr=swmr)
File "/Users/muazmaqbool/anaconda3/envs/soccer/lib/python3.7/site-packages/h5py/_hl/files.py", line 170, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 85, in h5py.h5f.open
OSError: Unable to open file (unable to open file: name = './model/trained_model.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

err when loading trained weights.

When I load the trained model, I get the err like this:

2020-05-06 21:10:40.156211: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory
2020-05-06 21:10:40.156517: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory
2020-05-06 21:10:40.156618: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
Using TensorFlow backend.
2020-05-06 21:10:41.169903: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1
2020-05-06 21:10:41.280627: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:17:00.0 name: GeForce GTX 1080 Ti computeCapability: 6.1
coreClock: 1.582GHz coreCount: 28 deviceMemorySize: 10.91GiB deviceMemoryBandwidth: 451.17GiB/s
2020-05-06 21:10:41.280870: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
2020-05-06 21:10:41.281167: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcublas.so.10'; dlerror: libcublas.so.10: cannot open shared object file: No such file or directory
2020-05-06 21:10:41.281241: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcufft.so.10'; dlerror: libcufft.so.10: cannot open shared object file: No such file or directory
2020-05-06 21:10:41.281304: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcurand.so.10'; dlerror: libcurand.so.10: cannot open shared object file: No such file or directory
2020-05-06 21:10:41.281363: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcusolver.so.10'; dlerror: libcusolver.so.10: cannot open shared object file: No such file or directory
2020-05-06 21:10:41.281426: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcusparse.so.10'; dlerror: libcusparse.so.10: cannot open shared object file: No such file or directory
2020-05-06 21:10:41.283925: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7
2020-05-06 21:10:41.283959: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1592] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2020-05-06 21:10:41.284263: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA
2020-05-06 21:10:41.303529: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3450000000 Hz
2020-05-06 21:10:41.303999: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x562a76d5a100 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-05-06 21:10:41.304069: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2020-05-06 21:10:41.616838: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x562a76dc00d0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-05-06 21:10:41.616993: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): GeForce GTX 1080 Ti, Compute Capability 6.1
2020-05-06 21:10:41.617248: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-05-06 21:10:41.617344: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]
(None, None, None, 1024)
(None, None, None, 1024)
WARNING:tensorflow:From /media/Store1/xar/mrcnn/model.py:794: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
Traceback (most recent call last):
File "detect.py", line 113, in
model = load_model_custom(InferenceConfig())
File "detect.py", line 63, in load_model_custom
model.load_weights('./model/trained_model.h5', by_name=True)
File "/media/Store1/xar/mrcnn/model.py", line 2295, in load_weights
saving.load_weights_from_hdf5_group_by_name(f, layers)
File "/media/Store1/xar/anaconda3/envs/keras/lib/python3.7/site-packages/keras/engine/saving.py", line 1309, in load_weights_from_hdf5_group_by_name
' element(s).')
ValueError: Layer #292 (named "contextual__attention_1") expects 29 weight(s), but the saved weights have 15 element(s).

The err said that the weight is not consistent with the model, how can I fix it?

Which annotations in Coco hand big are reliable?

Hello,
In the COCO Hand big dataset annotations readme, you mentioned " we obtained the COCO-Hand dataset that has 26499 images with a total of 45671 hands", however, there are 120000+ annotations in the file. So my question is Which annotations are the reliable ones?

Slow inference runtime?

Hi !

Thank you for the great work !

I had a question about the inference time, do you have an indicative idea of how long a forward pass of your model takes ? (for instance on your Titan GPU, either on a single or a batch of images ?)

When I run your model (without any modification) on a V100 Tesla I obersve long runtimes (>2 seconds for a forward pass on a 456x256 image) for the line

result = model.detect([img], verbose=0)[0] from here

I am using the command python -W ignore detect.py --image_dir /path/to/my/images.

Thank you for any help you might provide!

All the best,

Yana

how to determine which hand is right or left?

@SupreethN , thanks for your great work, but I also curious about when detecting two hands in an image which only has one person, is there any way to decide which hand is right or left after cropped the hand according to the bounding box?

Can't load model weights

For line 63 in detect.py 'model.load_weights('./model/trained_model.h5', by_name=True)':
OSError: Unable to open file (unable to open file: name = './model/trained_model.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
When I change to 'model.load_weights('./model/trained_weights.h5', by_name=True)':
ValueError: Layer #292 (named "contextual__attention_1") expects 29 weight(s), but the saved weights have 15 element(s).

ValueError: Error when checking : expected input_image to have shape (None, None, 3) but got array with shape (1024, 1024, 4)

I'm trying to use your model for my datasets.

When i run command python -W ignore detect.py --image_dir ../valid_imgs/ , it produces following error:

WARNING:tensorflow:From /home/ubuntu/projects/Clean_data/Hand-CNN-master/mrcnn/model.py:740: The name tf.sets.set_intersection is deprecated. Please use tf.sets.intersection instead.

WARNING:tensorflow:From /home/ubuntu/projects/Clean_data/Hand-CNN-master/mrcnn/model.py:794: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.cast` instead.
Processing image:  13671206_703416493140751_1501018506_n.jpg
Traceback (most recent call last):
  File "detect.py", line 114, in <module>
    detect(model,img_dir)
  File "detect.py", line 91, in detect
    result = model.detect([img], verbose=0)[0]
  File "/home/ubuntu/projects/Clean_data/Hand-CNN-master/mrcnn/model.py", line 2702, in detect
    self.keras_model.predict([molded_images, image_metas, anchors], verbose=0)
  File "/home/ubuntu/.local/lib/python3.7/site-packages/keras/engine/training.py", line 1782, in predict
    check_batch_axis=False)
  File "/home/ubuntu/.local/lib/python3.7/site-packages/keras/engine/training.py", line 120, in _standardize_input_data
    str(data_shape))
ValueError: Error when checking : expected input_image to have shape (None, None, 3) but got array with shape (1024, 1024, 4)

What should i do?
I use tensorflow 1.14.0 because i can't find tensorflow 1.4.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.