You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
795 B
26 lines
795 B
6 months ago
|
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()))
|