Spaces:
Runtime error
Runtime error
Update detection_utils.py
Browse files- detection_utils.py +1 -28
detection_utils.py
CHANGED
|
@@ -4,7 +4,6 @@ import gradio as gr
|
|
| 4 |
from matplotlib import cm
|
| 5 |
import torch
|
| 6 |
import torchvision
|
| 7 |
-
from dlclive import DLCLive, Processor
|
| 8 |
import matplotlib
|
| 9 |
from PIL import Image, ImageColor, ImageFont, ImageDraw
|
| 10 |
import numpy as np
|
|
@@ -87,30 +86,4 @@ def crop_animal_detections(img_in,
|
|
| 87 |
# add to list
|
| 88 |
list_np_animal_crops.append(crop_np)
|
| 89 |
|
| 90 |
-
return list_np_animal_crops
|
| 91 |
-
|
| 92 |
-
##########################################
|
| 93 |
-
def predict_dlc(list_np_crops,
|
| 94 |
-
kpts_likelihood_th,
|
| 95 |
-
DLCmodel,
|
| 96 |
-
dlc_proc):
|
| 97 |
-
|
| 98 |
-
# run dlc thru list of crops
|
| 99 |
-
dlc_live = DLCLive(DLCmodel, processor=dlc_proc)
|
| 100 |
-
dlc_live.init_inference(list_np_crops[0])
|
| 101 |
-
|
| 102 |
-
list_kpts_per_crop = []
|
| 103 |
-
all_kypts = []
|
| 104 |
-
np_aux = np.empty((1,3)) # can I avoid hardcoding here?
|
| 105 |
-
for crop in list_np_crops:
|
| 106 |
-
# scale crop here?
|
| 107 |
-
keypts_xyp = dlc_live.get_pose(crop) # third column is llk!
|
| 108 |
-
# set kpts below threhsold to nan
|
| 109 |
-
|
| 110 |
-
#pdb.set_trace()
|
| 111 |
-
keypts_xyp[keypts_xyp[:,-1] < kpts_likelihood_th,:] = np_aux.fill(np.nan)
|
| 112 |
-
# add kpts of this crop to list
|
| 113 |
-
list_kpts_per_crop.append(keypts_xyp)
|
| 114 |
-
all_kypts.append(keypts_xyp)
|
| 115 |
-
|
| 116 |
-
return list_kpts_per_crop
|
|
|
|
| 4 |
from matplotlib import cm
|
| 5 |
import torch
|
| 6 |
import torchvision
|
|
|
|
| 7 |
import matplotlib
|
| 8 |
from PIL import Image, ImageColor, ImageFont, ImageDraw
|
| 9 |
import numpy as np
|
|
|
|
| 86 |
# add to list
|
| 87 |
list_np_animal_crops.append(crop_np)
|
| 88 |
|
| 89 |
+
return list_np_animal_crops
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|