Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Step 4: Defining model: "local variable 'idx' referenced before assignment" #8

Closed
davidjamespritchard opened this issue Sep 16, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@davidjamespritchard
Copy link

davidjamespritchard commented Sep 16, 2019

Hi Jake,

I am running DeepPoseKit in Colab (with GPU) using Windows 10, and everything goes smoothly up until the "Define a model" step in the model training notebook.

When I run:

model = StackedDenseNet(data_generator=train_generator, n_stacks=2)
model.get_config()

I get the error message below.

I have not changed any of the code other than add code to mount google drive so I can add my annotated .h5 file.

from google.colab import drive
drive.mount('/content/drive',force_remount=True)

annotations = sorted(glob.glob('/content/drive/My Drive/*.h5'))

I have tried the most release release, and still have the same issue.

Let me know if there is anything I can try on my end!

Cheers

David


UnboundLocalError Traceback (most recent call last)
in ()
----> 1 model = StackedDenseNet(data_generator=train_generator, n_stacks=2)
2 # model = DeepLabCut(train_generator)
3 # model = LEAP(train_generator)
4 # model = StackedHourglass(train_generator)
5 model.get_config()

3 frames
/usr/local/lib/python3.6/dist-packages/deepposekit/models/StackedDenseNet.py in init(self, data_generator, n_stacks, n_transitions, n_layers, growth_rate, bottleneck_factor, compression_factor, batchnorm, use_bias, activation, pooling, interpolation, subpixel, initializer, separable, squeeze_excite, **kwargs)
141 self.squeeze_excite = squeeze_excite
142 self.n_transitions = n_transitions
--> 143 super(StackedDenseNet, self).init(data_generator, subpixel, **kwargs)
144
145 def init_model(self):

/usr/local/lib/python3.6/dist-packages/deepposekit/models/engine.py in init(self, data_generator, subpixel, **kwargs)
32 self.subpixel = subpixel
33 if self.train_model is NotImplemented and 'skip_init' not in kwargs:
---> 34 self.init_model()
35 self.init_train_model()
36 if self.data_generator is not None:

/usr/local/lib/python3.6/dist-packages/deepposekit/models/StackedDenseNet.py in init_model(self)
186 activation=self.activation, pooling=self.pooling, interpolation=self.interpolation, batchnorm=self.batchnorm,
187 use_bias=self.use_bias, separable=self.separable, squeeze_excite=self.squeeze_excite,
--> 188 stack_idx=0, multiplier=1)([normalized])
189 outputs = [output0]
190 multiplier = self.n_transitions - self.data_generator.downsample_factor

/usr/local/lib/python3.6/dist-packages/deepposekit/models/layers/densenet.py in call(self, inputs)
321 if self.multiplier > 1:
322 self.multiplier -= 1
--> 323 transition_diff = len(down_list) + -1 * (idx + 1)
324 for idx in range(transition_diff + 1):
325 pool_size = int(2**(transition_diff - idx))

UnboundLocalError: local variable 'idx' referenced before assignment

@jgraving
Copy link
Owner

Thanks, I'll look into this. It seems to be related to image resolution. What resolution images are you using? Or if you could send me the dataset you're using that would be even better. Can you try using the DeepLabCut or StackedHourglass models to see if they also throw errors? E.g.:

#model = StackedDenseNet(data_generator=train_generator, n_stacks=2)
model = DeepLabCut(train_generator)
#model = LEAP(train_generator)
#model = StackedHourglass(train_generator)
model.get_config()

@davidjamespritchard
Copy link
Author

Hi Jake,

That might be it. I will check if I am using the correct resolution videos. I have tried the other model and both DeepLabCut and StackedHourglass seem to work.

@davidjamespritchard
Copy link
Author

Oh, I annotated the wrong set of videos (resolution 466x 466 rather than 448x 448). I will try with the other set of videos and let you know if it still occurs (will be a bit as need to reannotate).

@davidjamespritchard
Copy link
Author

Hi. With the 448 x 448 videos it all worked fine. Must have just been a resolution issue.

@jgraving jgraving reopened this Sep 17, 2019
@jgraving jgraving added the bug Something isn't working label Sep 17, 2019
@jgraving
Copy link
Owner

This should be fixed in the latest version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants