Commit 923a0594 authored by lijian6's avatar lijian6
Browse files

change to run by python


Signed-off-by: lijian6's avatarlijian <lijian6@sugon.com>
parent d7b98223
{
"0": "daisy",
"1": "dandelion",
"2": "roses",
"3": "sunflowers",
"4": "tulips"
}
\ No newline at end of file
......@@ -59,8 +59,8 @@ def Vit_Inference(args):
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='parameters to vaildate net')
parser.add_argument('--model', default='models/model.onnx', help='model path to inference')
parser.add_argument('--imgpath', default='', help='the image path')
parser.add_argument('--model', default='../Models/model.onnx', help='model path to inference')
parser.add_argument('--imgpath', default='./flower_photos/daisy/', help='the image path')
args = parser.parse_args()
Vit_Inference(args)
......@@ -43,8 +43,8 @@ def main(intputdir):
img = Image.open(img_path)
# [N, C, H, W]
img = data_transform(img)
print(img)
break
#print(img)
#break
# expand batch dimension
img = torch.unsqueeze(img, dim=0)
......
......@@ -35,7 +35,7 @@ def main(intputdir):
model.load_state_dict(torch.load(model_weight_path, map_location=device))
# create onnx model
model1 = migraphx.parse_onnx('./models/model.onnx')
model1 = migraphx.parse_onnx('../Models/model.onnx')
model1.compile(t=migraphx.get_target("gpu"), device_id=1)
# load image
......
{
"0": "daisy",
"1": "dandelion",
"2": "roses",
"3": "sunflowers",
"4": "tulips"
}
\ No newline at end of file
......@@ -182,7 +182,7 @@ int main(int argc, char *argv[])
int n = 0.0; size_t i;
for (i = 0; i < srcImages.size(); i++)
{
fprintf(stdout, "Inference for image[%d]:\n", i);
fprintf(stdout, "Inference for image[%ld]:\n", i);
cv::Mat srcImage = cv::imread(srcImages[i], 1);
migraphx::parameter_map inputData = preprocess(srcImage, classifier);
......@@ -190,7 +190,7 @@ int main(int argc, char *argv[])
postprocess(results[0], &n, inputs);
}
printf("All images:%d, match images:%d, Accuracy: %.3f%\n", i, n, ((float)n/i)*100);
printf("All images:%ld, match images:%d, Accuracy: %.2f% \n", i, n, ((float)n/i)*100);
}
if (S_IFREG & s.st_mode)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment