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

Update model.PoseEstimation to infer_output_dir #104

Merged
merged 27 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
be09507
revert: :memo: revert dark mode cell text color
A-Baji Nov 16, 2023
7c8ccdd
update yaml safe loading
sidhulyalkar Dec 6, 2023
b4a6ae0
update yaml safe load in dlc_reader
sidhulyalkar Dec 6, 2023
5b12e5e
Merge pull request #97 from A-Baji/main
kushalbakshi Dec 8, 2023
cc24a03
adjusted length of fields of varchar
MilagrosMarin Dec 11, 2023
71af568
Revert "adjusted length of fields of varchar"
MilagrosMarin Dec 12, 2023
3b635d6
update docstring for `model_description` varchar
MilagrosMarin Dec 12, 2023
ab3370a
Update `diagram_flowchart` as in array-ephys repo
MilagrosMarin Dec 21, 2023
28c55bc
move `dj.config()` from init to pipeline.py
MilagrosMarin Dec 21, 2023
820711e
setup install directly from GitHub instead of PyPI
MilagrosMarin Dec 21, 2023
cc0424c
minor update on tutorial markdowns as in array-ephys
MilagrosMarin Dec 22, 2023
ebe6f2b
minor change in dependency version in setup
MilagrosMarin Dec 22, 2023
8e0d9dd
change name of flowchart as in element-ca-imaging
MilagrosMarin Dec 22, 2023
a5e59e5
change name of `flowchart.svg` in notebook
MilagrosMarin Dec 22, 2023
95e10df
move `import os` from `__init__` to `tutorial_pipeline`
MilagrosMarin Dec 22, 2023
a50836d
fix `input_dir` and `output_dir` in the tutorial
MilagrosMarin Dec 22, 2023
fbab55d
Address the bug introduced by the latest update to the YAML dependency
MilagrosMarin Dec 22, 2023
0885f48
update outputs of the tutorial notebook
MilagrosMarin Dec 22, 2023
9b61920
from `safe_load` to `load`
MilagrosMarin Jan 1, 2024
d1b86ce
black formatting `dlc_reader.py`
MilagrosMarin Jan 3, 2024
fddad64
black formatting `tutorial.ipynb`
MilagrosMarin Jan 3, 2024
cd358eb
update `changelog` and `version.py`
MilagrosMarin Jan 4, 2024
abc10df
Refactor YAML loader instant. for consistency
MilagrosMarin Jan 4, 2024
d6fe551
add YAML object as recommended in parallel PR#102
MilagrosMarin Jan 4, 2024
499d85e
Merge pull request #103 from MilagrosMarin/main
kushalbakshi Jan 4, 2024
50f0d43
Merge branch 'main' of https://github.com/datajoint/element-deeplabcut
sidhulyalkar Jan 5, 2024
f53852d
update to create output_dir during pose estimation and update task
sidhulyalkar Jan 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.

## [0.2.11] - 2023-11-28
## [0.2.11] - 2023-01-04

+ Fix - Modify training to update init_weights path in pose_cfg.yaml
+ Fix - docstring typo
+ Fix - `dj.config()` setup moved to `tutorial_pipeline.py` instead of `__init__.py`
+ Bugfix - Resolved AttributeError from the latest update of the YAML dependency
+ Update - Flowchart images to increase consistency with other DataJoint Elements
+ Update - Elements installed directly from GitHub instead of PyPI

## [0.2.10] - 2023-11-20

Expand Down
3 changes: 1 addition & 2 deletions docs/src/.overrides/assets/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ html a[title="YouTube"].md-social__link svg {
/* --md-footer-fg-color: var(--dj-white); */
}

[data-md-color-scheme="slate"] td,
th {
[data-md-color-scheme="slate"] .jupyter-wrapper .Table Td {
color: var(--dj-black)
}
20 changes: 0 additions & 20 deletions element_deeplabcut/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
import os
import datajoint as dj

if "custom" not in dj.config:
dj.config["custom"] = {}

# overwrite dj.config['custom'] values with environment variables if available

dj.config["custom"]["database.prefix"] = os.getenv(
"DATABASE_PREFIX", dj.config["custom"].get("database.prefix", "")
)

dj.config["custom"]["dlc_root_data_dir"] = os.getenv(
"DLC_ROOT_DATA_DIR", dj.config["custom"].get("dlc_root_data_dir", "")
)

dj.config["custom"]["dlc_processed_data_dir"] = os.getenv(
"DLC_PROCESSED_DATA_DIR", dj.config["custom"].get("dlc_processed_data_dir", "")
)

db_prefix = dj.config["custom"].get("database.prefix", "")
19 changes: 14 additions & 5 deletions element_deeplabcut/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import cv2
import csv
import yaml
from ruamel.yaml import YAML
import inspect
import importlib
import numpy as np
Expand Down Expand Up @@ -239,8 +239,9 @@ def extract_new_body_parts(cls, dlc_config: dict, verbose: bool = True):
".yaml",
), f"dlc_config is neither dict nor filepath\n Check: {dlc_config_fp}"
if dlc_config_fp.suffix in (".yml", ".yaml"):
yaml = YAML(typ="safe", pure=True)
with open(dlc_config_fp, "rb") as f:
dlc_config = yaml.safe_load(f)
dlc_config = yaml.load(f)
# -- Check and insert new BodyPart --
assert "bodyparts" in dlc_config, f"Found no bodyparts section in {dlc_config}"
tracked_body_parts = cls.fetch("body_part")
Expand Down Expand Up @@ -307,7 +308,7 @@ class Model(dj.Manual):
config_template (longblob): Dictionary of the config for analyze_videos().
project_path ( varchar(255) ): DLC's project_path in config relative to root.
model_prefix ( varchar(32) ): Optional. Prefix for model files.
model_description ( varchar(1000) ): Optional. User-entered description.
model_description ( varchar(300) ): Optional. User-entered description.
TrainingParamSet (foreign key): Optional. Training parameters primary key.

Note:
Expand Down Expand Up @@ -381,8 +382,9 @@ def insert_new_model(
"dlc_config is not a filepath" + f"\n Check: {dlc_config_fp}"
)
if dlc_config_fp.suffix in (".yml", ".yaml"):
yaml = YAML(typ="safe", pure=True)
with open(dlc_config_fp, "rb") as f:
dlc_config = yaml.safe_load(f)
dlc_config = yaml.load(f)
if isinstance(params, dict):
dlc_config.update(params)

Expand Down Expand Up @@ -704,7 +706,14 @@ def make(self, key):
task_mode, output_dir = (PoseEstimationTask & key).fetch1(
"task_mode", "pose_estimation_output_dir"
)

if not output_dir:
output_dir = PoseEstimationTask.infer_output_dir(
key, relative=True, mkdir=True
)
# update pose_estimation_output_dir
PoseEstimationTask.update1(
{**key, "pose_estimation_output_dir": output_dir.as_posix()}
)
output_dir = find_full_path(get_dlc_root_data_dir(), output_dir)

# Triger PoseEstimation
Expand Down
5 changes: 3 additions & 2 deletions element_deeplabcut/readers/dlc_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd
from pathlib import Path
import pickle
import ruamel.yaml as yaml
from ruamel.yaml import YAML
from element_interface.utils import find_root_directory, dict_to_uuid
from .. import model
from ..model import get_dlc_root_data_dir
Expand Down Expand Up @@ -145,7 +145,8 @@ def yml(self):
"""json-structured config.yaml file contents"""
if self._yml is None:
with open(self.yml_path, "rb") as f:
self._yml = yaml.safe_load(f)
yaml = YAML(typ="safe", pure=True)
self._yml = yaml.load(f)
return self._yml

@property
Expand Down
82 changes: 81 additions & 1 deletion images/flowchart.drawio

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion images/flowchart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading