parent
70395a74c0
commit
5c4e016cdf
@ -0,0 +1,27 @@
|
|||||||
|
from 口罩检测.generate_data import custom_reader
|
||||||
|
from 口罩检测.util import train_parameters
|
||||||
|
import paddle as paddle
|
||||||
|
import paddle.fluid as fluid
|
||||||
|
from 口罩检测.VGGNet import VGGNet
|
||||||
|
import numpy as np
|
||||||
|
eval_reader = paddle.batch(custom_reader(train_parameters['eval_list_path']),
|
||||||
|
batch_size=train_parameters['train_batch_size'],
|
||||||
|
drop_last=True)
|
||||||
|
with fluid.dygraph.guard():
|
||||||
|
model,_ =fluid.load_dygraph('vgg')
|
||||||
|
vgg =VGGNet()
|
||||||
|
vgg.eval()
|
||||||
|
accs=[]
|
||||||
|
for batch_id,data in enumerate(eval_reader()):
|
||||||
|
x_data = np.array([x[0] for x in data]).astype('float32')
|
||||||
|
y_data = np.array([x[1] for x in data]).astype('int64')
|
||||||
|
y_data = y_data[:,np.newaxis]
|
||||||
|
|
||||||
|
img = fluid.dygraph.to_variable(x_data)
|
||||||
|
label =fluid.dygraph.to_variable(y_data)
|
||||||
|
|
||||||
|
out,acc= vgg(img,label)
|
||||||
|
|
||||||
|
label = np.argmax(out.numpy())
|
||||||
|
accs.append(acc.numpy()[0])
|
||||||
|
print(np.mean(accs))
|
Loading…
Reference in new issue