Creating a labeled image with the original human labels, as well as the DeepLabCut's!
(
frame,
DataCombined,
imagenr,
pcutoff,
Scorers,
bodyparts,
colors,
cfg,
labels=None,
scaling=1,
ax=None,
)
| 49 | |
| 50 | |
| 51 | def make_labeled_image( |
| 52 | frame, |
| 53 | DataCombined, |
| 54 | imagenr, |
| 55 | pcutoff, |
| 56 | Scorers, |
| 57 | bodyparts, |
| 58 | colors, |
| 59 | cfg, |
| 60 | labels=None, |
| 61 | scaling=1, |
| 62 | ax=None, |
| 63 | ): |
| 64 | """Creating a labeled image with the original human labels, as well as the |
| 65 | DeepLabCut's!""" |
| 66 | |
| 67 | if labels is None: |
| 68 | labels = ["+", ".", "x"] |
| 69 | alphavalue = cfg["alphavalue"] # .5 |
| 70 | dotsize = cfg["dotsize"] # =15 |
| 71 | |
| 72 | if ax is None: |
| 73 | if np.ndim(frame) > 2: # color image! |
| 74 | h, w, numcolors = np.shape(frame) |
| 75 | else: |
| 76 | h, w = np.shape(frame) |
| 77 | _, ax = prepare_figure_axes(w, h, scaling) |
| 78 | ax.imshow(frame, "gray") |
| 79 | for _scorerindex, loopscorer in enumerate(Scorers): |
| 80 | for bpindex, bp in enumerate(bodyparts): |
| 81 | if np.isfinite( |
| 82 | DataCombined[loopscorer][bp]["y"].iloc[imagenr] + DataCombined[loopscorer][bp]["x"].iloc[imagenr] |
| 83 | ): |
| 84 | y, x = ( |
| 85 | int(DataCombined[loopscorer][bp]["y"].iloc[imagenr]), |
| 86 | int(DataCombined[loopscorer][bp]["x"].iloc[imagenr]), |
| 87 | ) |
| 88 | if cfg["scorer"] not in loopscorer: |
| 89 | p = DataCombined[loopscorer][bp]["likelihood"].iloc[imagenr] |
| 90 | if p > pcutoff: |
| 91 | ax.plot( |
| 92 | x, |
| 93 | y, |
| 94 | labels[1], |
| 95 | ms=dotsize, |
| 96 | alpha=alphavalue, |
| 97 | color=colors(int(bpindex)), |
| 98 | ) |
| 99 | else: |
| 100 | ax.plot( |
| 101 | x, |
| 102 | y, |
| 103 | labels[2], |
| 104 | ms=dotsize, |
| 105 | alpha=alphavalue, |
| 106 | color=colors(int(bpindex)), |
| 107 | ) |
| 108 | else: # this is the human labeler |
no test coverage detected