from PIL import Image
import paddle.fluid as fluid
import numpy as np
from 手势识别.build_model import FullNet_Model
def load_image(path):
    img =Image.open(path)
    img = img.resize((100,100),Image.ANTIALIAS)
    img = np.array(img).astype('float32')
    img = img.transpose(2,0,1)
    img = img/255.0
    print(img.shape)
    return img
with fluid.dygraph.guard():
    infer_path ='test.jpg'
    model = FullNet_Model()
    model_dict,_ =fluid.load_dygraph('./FullNet_Model')
    model.load_dict(model_dict)

    model.eval() #开启评估模式

    infer_image = load_image(infer_path)
    infer_image = infer_image[np.newaxis,:,:,:]
    infer_image =fluid.dygraph.to_variable(infer_image)

    result = model(infer_image)
    print(np.argmax(result.numpy()))