Skip to content

Commit e6321e9

Browse files
committed
fixed multiple errors in MADLC
1 parent 7bb7ace commit e6321e9

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

utils/configloader.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ def get_script_path():
2323
with open(cfg_path) as cfg_file:
2424
dsc_config.read_file(cfg_file)
2525

26-
# DeepLabCut
27-
deeplabcut_config = dict(dsc_config.items('DeepLabCut'))
2826

2927
#poseestimation
3028
MODEL_ORIGIN = dsc_config['Pose Estimation'].get('MODEL_ORIGIN')

utils/poser.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
from scipy.ndimage.measurements import label, maximum_position
1717
from scipy.ndimage.morphology import generate_binary_structure, binary_erosion
1818
from scipy.ndimage.filters import maximum_filter
19-
from utils.configloader import deeplabcut_config, MODEL_ORIGIN
19+
from utils.configloader import MODEL_ORIGIN, MODEL_NAME, MODEL_PATH
2020

21-
MODEL = deeplabcut_config['model']
22-
DLC_PATH = deeplabcut_config['dlc_path']
2321

2422
# trying importing functions using deeplabcut module, if DLC 2 is installed correctly
2523
try:
@@ -31,7 +29,7 @@
3129
# if not DLC 2 is not installed, try import from DLC 1 the old way
3230
except ImportError:
3331
# adding DLC posing path and loading modules from it
34-
sys.path.insert(0, DLC_PATH + "/pose-tensorflow")
32+
sys.path.insert(0,MODEL_PATH + "/pose-tensorflow")
3533
from config import load_config
3634
from nnet import predict
3735
models_folder = 'pose-tensorflow/models/'
@@ -43,7 +41,7 @@ def load_deeplabcut():
4341
4442
:return: tuple of DeepLabCut config, TensorFlow session, inputs and outputs
4543
"""
46-
model = os.path.join(DLC_PATH, models_folder, MODEL)
44+
model = os.path.join(MODEL_PATH, models_folder, MODEL_NAME)
4745
cfg = load_config(os.path.join(model, 'test/pose_cfg.yaml'))
4846
snapshots = sorted([sn.split('.')[0] for sn in os.listdir(model + '/train/') if "index" in sn])
4947
cfg['init_weights'] = model + '/train/' + snapshots[-1]
@@ -237,7 +235,7 @@ def extract_to_animal_skeleton(coords):
237235

238236
return skeletons
239237
animal_skeletons = extract_to_animal_skeleton(pose['coordinates'])
240-
# animal_skeletons = list(animal_skeletons.values())
238+
animal_skeletons = list(animal_skeletons.values())
241239

242240
return animal_skeletons
243241

@@ -294,6 +292,6 @@ def calculate_skeletons(peaks: dict, animals_number: int) -> list:
294292
raise ValueError('Multiple animals are currently not supported by DLC-LIVE.'
295293
' If you are using differently colored animals, please refere to the bodyparts directly.')
296294

297-
295+
return animal_skeletons
298296

299297

0 commit comments

Comments
 (0)