added dlc live script
Browse files
app.py
CHANGED
|
@@ -27,6 +27,29 @@ def yolo(im, size=640):
|
|
| 27 |
results.render() # updates results.imgs with boxes and labels
|
| 28 |
return Image.fromarray(results.imgs[0])
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
#Layouts and descriptions
|
| 31 |
title = "MegaDetector and DeepLabcutLive"
|
| 32 |
description = "Interact with MegaDetector and DeeplabCutLive for pose estimation"
|
|
|
|
| 27 |
results.render() # updates results.imgs with boxes and labels
|
| 28 |
return Image.fromarray(results.imgs[0])
|
| 29 |
|
| 30 |
+
|
| 31 |
+
def dlclive_pose(model, crop_np, crop, fname, index,dlc_proc):
|
| 32 |
+
model = torch.hub.load('ultralytics/yolov5', 'custom', "model_weights/md_v5a.0.0.pt")
|
| 33 |
+
|
| 34 |
+
dlc_live = DLCLive(model, processor=dlc_proc)
|
| 35 |
+
dlc_live.init_inference(crop_np)
|
| 36 |
+
keypts = dlc_live.get_pose(crop_np)
|
| 37 |
+
savetxt(str(fname)+ '_' + str(index) + '.csv' , keypts, delimiter=',')
|
| 38 |
+
xpose = []
|
| 39 |
+
ypose = []
|
| 40 |
+
for key in keypts[:,2]:
|
| 41 |
+
# if key > 0.05: # which value do we need here?
|
| 42 |
+
i = np.where(keypts[:,2]==key)
|
| 43 |
+
xpose.append(keypts[i,0])
|
| 44 |
+
ypose.append(keypts[i,1])
|
| 45 |
+
plt.imshow(crop)
|
| 46 |
+
plt.scatter(xpose[:], ypose[:], 40, color='cyan')
|
| 47 |
+
plt.savefig(str(fname)+ '_' + str(index) + '.png')
|
| 48 |
+
plt.show()
|
| 49 |
+
plt.clf()
|
| 50 |
+
|
| 51 |
+
dlc_proc = Processor()
|
| 52 |
+
|
| 53 |
#Layouts and descriptions
|
| 54 |
title = "MegaDetector and DeepLabcutLive"
|
| 55 |
description = "Interact with MegaDetector and DeeplabCutLive for pose estimation"
|