Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run model for new images ? #18

Open
gumush opened this issue Aug 6, 2019 · 0 comments
Open

How to run model for new images ? #18

gumush opened this issue Aug 6, 2019 · 0 comments

Comments

@gumush
Copy link

gumush commented Aug 6, 2019

I want to run model to process my images. My data has not grand truth annotations and keypoints.
How can i process my images ?

`import argparse
import numpy as np
from tqdm import tqdm

from modeling.build_model import Pose2Seg
from datasets.CocoDatasetInfo import CocoDatasetInfo, annToMask
from pycocotools import mask as maskUtils
import cv2, os
import matplotlib
import matplotlib.pyplot as plt

from skimage import data, io, filters

import os
import cv2
import json
model = Pose2Seg().cuda()
model.init('pose2seg_release.pkl')
ImageRoot = './data/coco2017/val2017'
AnnoFile = './data/coco2017/annotations/person_keypoints_val2017_pose2seg.json'
datainfos = CocoDatasetInfo(ImageRoot, AnnoFile, onlyperson=True, loadimg=True)
model.eval()
results_segm = []
imgIds = []
rawdata = datainfos[1]
img = rawdata['data']
print(rawdata['image'])
image_id = rawdata['id']
height, width = img.shape[0:2]
gt_kpts = np.float32(rawdata['gt_keypoints']).transpose(0, 2, 1)  # (N, 17, 3)
gt_segms = rawdata['segms']
gt_masks = np.array([annToMask(segm, height, width) for segm in gt_segms])
output = model([img], [gt_kpts], [gt_masks])
for mask in output[0]:
    maskencode = maskUtils.encode(np.asfortranarray(mask))
    maskencode['counts'] = maskencode['counts'].decode('ascii')
    results_segm.append({
        "image_id": image_id,
        "category_id": 1,
        "score": 1.0,
        "segmentation": maskencode
    })
imgIds.append(image_id)` 

model need inputs as keypoints and masks.

output = model([img], [gt_kpts], [gt_masks])

I need to create mask and keypoints from my image and visualize them
Great work , thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant