Skip to content

Commit 7886b10

Browse files
committed
added single instance functionality for SLEAP models
1 parent 2cd04b8 commit 7886b10

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

DeepLabStream.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,16 @@ def get_pose_mp(input_q, output_q):
323323
if input_q.full():
324324
index, frame = input_q.get()
325325
start_time = time.time()
326-
frame = frame[:, :, ::-1]
327-
#this is weird, but i without it, it does not seem to work...
328-
frames = np.array([frame])
326+
input_frame = frame[:, :, ::-1]
327+
#this is weird, but without it, it does not seem to work...
328+
frames = np.array([input_frame])
329329
prediction = sleap_model.predict(frames[[0]], batch_size=1)
330-
peaks = prediction['instance_peaks'][0, :]
330+
#check if this is multiple animal instances or single animal model
331+
if sleap_model.name == 'single_instance_inference_model':
332+
#get predictions (wrap it again, so the behavior is the same for both model types)
333+
peaks = np.array([prediction['peaks'][0, :]])
334+
else:
335+
peaks = prediction['instance_peaks'][0, :]
331336
analysis_time = time.time() - start_time
332337
output_q.put((index,peaks,analysis_time))
333338
else:

0 commit comments

Comments
 (0)