从ML Engine中的对象检测模型获得非常低的置信度得分

时间:2018-12-18 09:04:35

标签: python google-app-engine google-cloud-platform deep-learning

def predict_json(project, model, instances, version=None):
    service = googleapiclient.discovery.build('ml', 'v1')
    name = 'projects/{}/models/{}'.format(project, model)

    if version is not None:
        name += '/versions/{}'.format(version)

    response = service.projects().predict(
        name=name,
        body={'instances': instances}
    ).execute()

    if 'error' in response:
        raise RuntimeError(response['error'])

    return response['predictions']
    
width = 640
height = 640
instances=[]
orig_images=[]

vr = vreader("running.mp4",num_frames=2)
for v in vr:
	orig_images.append(v)
	img = Image.fromarray(v)
	img = img.resize((width, height), Image.ANTIALIAS)
	output_str = io.BytesIO()
	img.save(output_str, "JPEG")
	instances.append({'b64': base64.b64encode(output_str.getvalue())})
	output_str.close()	

predict_json("deeplearning","obje",instances,"objecttracking")

置信度和边界框完全不正确。我需要做任何预处理吗?我已经从Tensorflow模型动物园获得模型,而我的模型是ssd resnet。

0 个答案:

没有答案