Skip to content

SpatiotemporalAdaptation kwargs #2282

@rahim-hashim

Description

@rahim-hashim

Is there an existing issue for this?

  • I have searched the existing issues

Bug description

When running SpatiotemporalAdaptation adapter.adaptation_training as defined in the documentation, there is an error looking for the adapt_iterations kwargs, even though it is assigned to the adapter object in adapter.before_adapt_inference() by default as 1000.

video_path = video_path_list[0]
superanimal_name = 'superanimal_quadruped'

from deeplabcut.modelzoo.api import SpatiotemporalAdaptation
adapter = SpatiotemporalAdaptation(
    video_path,
    superanimal_name,
    modelfolder = 'temp',
    videotype = videotype,
)

adapter.before_adapt_inference()
adapter.adaptation_training()        # <–––––- error
adapter.after_adapt_inference()

You can confirm by running adapter.adapt_iterations after adapter.before_adapt_inference() and seeing the value. It is fixed easily by assigning a new kwarg adapt_iterations = 1000 and feeding it into the adapter_training:

video_path = video_path_list[0]
superanimal_name = 'superanimal_quadruped'
adapt_iterations = 1000

from deeplabcut.modelzoo.api import SpatiotemporalAdaptation
adapter = SpatiotemporalAdaptation(
    video_path,
    superanimal_name,
    modelfolder = 'temp',
    videotype = videotype,
)

adapter.before_adapt_inference()
adapter.adaptation_training(adapt_iterations=adapt_iterations)  # <–––––- error looking for kwargs
adapter.after_adapt_inference()

even though this step should not be needed, or else included in the specifications. Small issue, and simple solution, but worth fixing for future use.

Operating System

MacOS Ventura

DeepLabCut version

DLC 2.3.5

DeepLabCut mode

single animal

Device type

M1

Steps To Reproduce

No response

Relevant log output

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[24], line 14
      6 adapter = SpatiotemporalAdaptation(
      7     video_path,
      8     superanimal_name,
      9     modelfolder = 'temp',
     10     videotype = videotype,
     11 )
     13 adapter.before_adapt_inference()
---> 14 adapter.adaptation_training()
     15 adapter.after_adapt_inference()

File ~/Desktop/DeepLabCut/deeplabcut/modelzoo/api/spatiotemporal_adapt.py:175, in SpatiotemporalAdaptation.adaptation_training(self, displayiters, saveiters, **kwargs)
    172 if self.modelfolder != "":
    173     os.makedirs(self.modelfolder, exist_ok=True)
--> 175 self.adapt_iterations = kwargs['adapt_iterations']
    178 if os.path.exists(os.path.join(self.modelfolder, f"snapshot-{self.adapt_iterations}.index")):        
    179     print (f'model checkpoint snapshot-{self.adapt_iterations}.index exists, skipping the video adaptation')            

KeyError: 'adapt_iterations'

Anything else?

No response

Code of Conduct

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions