jgraving / DeepPoseKit

a toolkit for pose estimation using deep learning
http://deepposekit.org
Apache License 2.0
391 stars 90 forks source link

Train a model #83

Closed relaxwang0714 closed 3 years ago

relaxwang0714 commented 3 years ago

When I try the example of “DeepPoseKit Step 3 - Train a model” in colab, it throws the following error

data_generator = DataGenerator(HOME + '/deepposekit-data/datasets/fly/annotation_data_release.h5')

AttributeError Traceback (most recent call last)

in () ----> 1 data_generator = DataGenerator(HOME + '/deepposekit-data/datasets/fly/annotation_data_release.h5') /usr/local/lib/python3.7/dist-packages/deepposekit/io/DataGenerator.py in __init__(self, datapath, dataset, mode, **kwargs) 79 else: 80 self.mode = mode ---> 81 self.annotated = np.all(h5file["annotated"].value, axis=1) 82 self.annotated_index = np.where(self.annotated)[0] 83 self.n_annotated = self.annotated_index.shape[0] AttributeError: 'Dataset' object has no attribute 'value'
moshiroi commented 3 years ago

I also get this when following the first example "step1_create_annotation_set". I've posted the error returned below.


AttributeError Traceback (most recent call last)

in ----> 1 data_generator = DataGenerator('dpk-data/datasets/fly/annotation_data_release.h5', mode="full") ~\AppData\Local\Programs\Python\Python39\lib\site-packages\deepposekit\io\DataGenerator.py in __init__(self, datapath, dataset, mode, **kwargs) 79 else: 80 self.mode = mode ---> 81 self.annotated = np.all(h5file["annotated"].value, axis=1) 82 self.annotated_index = np.where(self.annotated)[0] 83 self.n_annotated = self.annotated_index.shape[0] AttributeError: 'Dataset' object has no attribute 'value'
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] commented 3 years ago

This issue has been automatically closed because it has not had recent activity.

71c commented 1 year ago

I encountered this same problem. (This issue is also mentioned in #90.) I found the source of the problem. If you look in the file where that happens, deepposekit/io/DataGenerator.py, line 81 (in __init__) you see that h5file["annotated"] is a Dataset object which is part of h5py library. I found the solution at this StackOverflow post.

According to the post, we should do to fix this problem is the following (if we don't want to edit the code of DeepPoseKit): downgrade h5py to use the old syntax: pip3 install --upgrade pip && pip3 install h5py=='2.9.0'

This worked for me.

martvelge commented 11 months ago

Just faced it. Open /usr/local/lib/python3.7/dist-packages/deepposekit/io/DataGenerator.py, find the line with the error and replace .value with [()]. Then restart runtime, reimport libraries and create a dataset again.