mwmathis commited on
Commit
000b3e1
Β·
1 Parent(s): ca54db1

Create dlc_utils.py

Browse files
Files changed (1) hide show
  1. dlc_utils.py +31 -0
dlc_utils.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import deeplabcut
2
+ from tkinter import W
3
+ import gradio as gr
4
+ import numpy as np
5
+
6
+
7
+ ##########################################
8
+ def predict_dlc(list_np_crops,
9
+ kpts_likelihood_th,
10
+ DLCmodel,
11
+ dlc_proc):
12
+
13
+ # run dlc thru list of crops
14
+ dlc_live = DLCLive(DLCmodel, processor=dlc_proc)
15
+ dlc_live.init_inference(list_np_crops[0])
16
+
17
+ list_kpts_per_crop = []
18
+ all_kypts = []
19
+ np_aux = np.empty((1,3)) # can I avoid hardcoding here?
20
+ for crop in list_np_crops:
21
+ # scale crop here?
22
+ keypts_xyp = dlc_live.get_pose(crop) # third column is llk!
23
+ # set kpts below threhsold to nan
24
+
25
+ #pdb.set_trace()
26
+ keypts_xyp[keypts_xyp[:,-1] < kpts_likelihood_th,:] = np_aux.fill(np.nan)
27
+ # add kpts of this crop to list
28
+ list_kpts_per_crop.append(keypts_xyp)
29
+ all_kypts.append(keypts_xyp)
30
+
31
+ return list_kpts_per_crop