Can Lightweight-OpenPose Pytorch-Model be used with SwiftOpenPose?
This page describes the modification script of the model conversion script, SwiftOpenPose.
If the image ignores the scale, the inference is poor.
Remember this result and look at the next.
Yeah! Converted to CoreML-Model without major problems.
It was confirmed that it works with SwiftOpenPose.
- Google Colaboratory https://gist.github.com/mbotsu/ad9b97558a163304725244b5ee898588
edited Lightweight-OpenPose demo.py
import PIL.Image
import coremltools
def load_image(path, resize_to=None):
# resize_to: (Width, Height)
img = PIL.Image.open(path)
if resize_to is not None:
img = img.resize(resize_to, PIL.Image.ANTIALIAS)
img_np = np.array(img).astype(np.float32)
return img_np, img
_, img = load_image('./hadou.jpg', resize_to=(360, 360))
model = coremltools.models.MLModel('./small_model2.mlmodel')
out_dict = model.predict({'data': img})
stage2_heatmaps = out_dict['stage_1_output_1_heatmaps'].squeeze()
stage2_pafs = out_dict['stage_1_output_0_pafs'].squeeze()
heatmaps = np.transpose(stage2_heatmaps,(1, 2, 0))
pafs = np.transpose(stage2_pafs,(1, 2, 0))
heatmaps = cv2.resize(heatmaps, (0, 0), fx=upsample_ratio, fy=upsample_ratio, interpolation=cv2.INTER_CUBIC)
pafs = cv2.resize(pafs, (0, 0), fx=upsample_ratio, fy=upsample_ratio, interpolation=cv2.INTER_CUBIC)
@mbotsu How much process speed in mobile device?