Skip to content

evaluate_network method possibly searches for hardcoded config.yaml filename? #2733

@anthonyattacks

Description

@anthonyattacks

Is there an existing issue for this?

  • I have searched the existing issues

Bug description

Hello,

Running through my pipeline, I've had one specific method fail despite every other method using the proper (in our case: d1.config.yaml) file. Here's my code, and here's the error:

code:

# %%capture --no-stderr evalModel

# Track / log time, start
timeStart, startCalc = datetime.now().time(), time.time()
print(f"Time began: {timeStart.strftime('%H:%M:%S')}")

deeplabcut.evaluate_network(configPath, plotting = True)
# print(configPath)

# Track / log time, end, elapsed
timeStop, stopCalc = datetime.now().time(), time.time()
print(f"Time completed: {timeStop.strftime('%H:%M:%S')}")
print(f"Time elapsed: {round((stopCalc - startCalc)/60, 2)} minutes")

# Config path prints correctly; DLC is doing something to the path in the background.

# Times:
# All Default Settings: 

I've checked with print, the variable the config file name is stored in is still correct. It looks like the method is looking for "config.yaml" instead of what I have input as the config filename. This doesn't happen with any other method in my pipeline. Looking at the error, it looks like it's hardcoded to look for config.yaml instead of *config.yaml? We have an interest in preserving config.yaml for individual camera names irrespective of directory path, so just changing the name of config.yaml to match DLC convention wouldn't solve the problem given our use-case. Let me know if there are any thoughts. We're using the conda environment, which (having updated the environment) doesn't appear to be on the most recent version of DLC / gives an update prompt, so it's possible that this was also fixed in the most recent version.

Operating System

operating system: Ubuntu 24.04

DeepLabCut version

dlc version: 2.2.2, I believe?

DeepLabCut mode

single animal

Device type

gpu: Nvidia - 3060

Steps To Reproduce

In a conda environment, run:

deeplabcut.evaluate_network(configPath, plotting = True)

where configPath ends with a file that isn't exactly config.yaml (eg. d1.config.yaml)

Relevant log output

{
	"name": "FileNotFoundError",
	"message": "Config file at /home/happy/programming/deepLabCut/finches/dlcProject/d1/finchD1-happy-2024-09-02/config.yaml not found. Please make sure that the file exists and/or that you passed the path of the config file correctly!",
	"stack": "---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[83], line 7
      4 timeStart, startCalc = datetime.now().time(), time.time()
      5 print(f\"Time began: {timeStart.strftime('%H:%M:%S')}\")
----> 7 deeplabcut.evaluate_network(configPath, plotting = True)
      9 # Track / log time, end, elapsed
     10 timeStop, stopCalc = datetime.now().time(), time.time()

File ~/Downloads/enter/envs/finchenv/lib/python3.10/site-packages/deeplabcut/compat.py:476, in evaluate_network(config, Shuffles, trainingsetindex, plotting, show_errors, comparisonbodyparts, gputouse, rescale, modelprefix, per_keypoint_evaluation, snapshots_to_evaluate, engine, **torch_kwargs)
    474     from deeplabcut.pose_estimation_pytorch.apis import evaluate_network
    475     _update_device(gputouse, torch_kwargs)
--> 476     return evaluate_network(
    477         config,
    478         shuffles=Shuffles,
    479         trainingsetindex=trainingsetindex,
    480         plotting=plotting,
    481         show_errors=show_errors,
    482         modelprefix=modelprefix,
    483         **torch_kwargs,
    484     )
    486 raise NotImplementedError(f\"This function is not implemented for {engine}\")

File ~/Downloads/enter/envs/finchenv/lib/python3.10/site-packages/deeplabcut/pose_estimation_pytorch/apis/evaluate.py:393, in evaluate_network(config, shuffles, trainingsetindex, snapshotindex, device, plotting, show_errors, transform, modelprefix, detector_snapshot_index)
    391 for train_set_index in train_set_indices:
    392     for shuffle in shuffles:
--> 393         loader = DLCLoader(
    394             config=Path(cfg[\"project_path\"]) / \"config.yaml\",
    395             shuffle=shuffle,
    396             trainset_index=train_set_index,
    397             modelprefix=modelprefix,
    398         )
    399         loader.evaluation_folder.mkdir(exist_ok=True, parents=True)
    401         if device is not None:

File ~/Downloads/enter/envs/finchenv/lib/python3.10/site-packages/deeplabcut/pose_estimation_pytorch/data/dlcloader.py:47, in DLCLoader.__init__(self, config, trainset_index, shuffle, modelprefix)
     39 \"\"\"
     40 Args:
     41     config: path to the DeepLabCut project config
   (...)
     44     modelprefix: the modelprefix for the shuffle
     45 \"\"\"
     46 self._project_root = Path(config).parent
---> 47 self._project_config = af.read_config(str(config))
     48 self._shuffle = shuffle
     49 self._train_frac = self._project_config[\"TrainingFraction\"][trainset_index]

File ~/Downloads/enter/envs/finchenv/lib/python3.10/site-packages/deeplabcut/utils/auxiliaryfunctions.py:238, in read_config(configname)
    235                 raise
    237 else:
--> 238     raise FileNotFoundError(
    239         f\"Config file at {path} not found. Please make sure that the file exists and/or that you passed the path of the config file correctly!\"
    240     )
    241 return cfg

FileNotFoundError: Config file at /home/happy/programming/deepLabCut/finches/dlcProject/d1/finchD1-happy-2024-09-02/config.yaml not found. Please make sure that the file exists and/or that you passed the path of the config file correctly!"
}

Anything else?

No response

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions