File size: 1,776 Bytes
000b3e1
 
 
 
91ae7b8
000b3e1
 
 
 
 
 
 
 
 
79d237e
000b3e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ea67981
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import deeplabcut
from tkinter import W
import gradio as gr
import numpy as np
from dlclive import DLCLive, Processor


##########################################
def predict_dlc(list_np_crops,
                kpts_likelihood_th,
                DLCmodel,
                dlc_proc):
    
    # run dlc thru list of crops
    dlc_live = DLCLive(DLCmodel[0], processor=dlc_proc)
    dlc_live.init_inference(list_np_crops[0])

    list_kpts_per_crop = []
    all_kypts  = []
    np_aux = np.empty((1,3)) # can I avoid hardcoding here?
    for crop in list_np_crops:
        # scale crop here?
        keypts_xyp = dlc_live.get_pose(crop) # third column is llk!
        # set kpts below threhsold to nan
        
        #pdb.set_trace()
        keypts_xyp[keypts_xyp[:,-1] < kpts_likelihood_th,:] = np_aux.fill(np.nan)
        # add kpts of this crop to list 
        list_kpts_per_crop.append(keypts_xyp)
        all_kypts.append(keypts_xyp)
    
    return list_kpts_per_crop

# WIP error
'''
File "/home/user/app/dlc_utils.py", line 15, in predict_dlc
    dlc_live = DLCLive(DLCmodel, processor=dlc_proc)
  File "/home/user/.local/lib/python3.8/site-packages/dlclive/dlclive.py", line 155, in __init__
    self.read_config()
  File "/home/user/.local/lib/python3.8/site-packages/dlclive/dlclive.py", line 166, in read_config
    cfg_path = Path(self.path).resolve() / "pose_cfg.yaml"
  File "/usr/local/lib/python3.8/pathlib.py", line 1041, in __new__
    self = cls._from_parts(args, init=False)
  File "/usr/local/lib/python3.8/pathlib.py", line 682, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/usr/local/lib/python3.8/pathlib.py", line 666, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
'''