(image, lmks,eps=1)
| 162 | |
| 163 | |
| 164 | def draw_facepose(image, lmks,eps=1): |
| 165 | H,W = image.shape[2:] |
| 166 | canvas = np.zeros(shape=(H, W, 3), dtype=np.uint8) |
| 167 | count =0 |
| 168 | for lmk in lmks: |
| 169 | x, y = int(lmk[0]),int(lmk[1]) |
| 170 | if (x > eps and y > eps) and (x < W and y < H): |
| 171 | # print(x,y) |
| 172 | count+=1 |
| 173 | cv2.circle(canvas, (x, y), 3*H//800, (255, 255, 255), thickness=-1) |
| 174 | |
| 175 | |
| 176 | out = torch.from_numpy(canvas)/255 |
| 177 | out = out.permute(2,0,1)[None,...].to(image.device) |
| 178 | out = torch.where(out==0,image,out) |
| 179 | return out |
| 180 | |
| 181 | |
| 182 | def to_tensor(x,from_numpy=True,dtype='float32',device='cuda:0'): |
nothing calls this directly
no outgoing calls
no test coverage detected