Hello, I am writing code in Vivado SDK 2018.3 to drive the IP core generated by HLS to realize handwritten digit recognition. Now there is no problem with the result of a single call, but the first result is correct and the subsequent results are wrong when the loop is called multiple times. For example, I recognize the number 0 now, and he is correct. But I recognize multiple pictures in a row, only the first result is correct, and the other results are all wrong, and I need to reprogram the fpga to recognize it correctly. I have checked the input and tested each image individually, and they are all right. What may be the reason? Here are part of my codes:
Question
dddddddq
Hello, I am writing code in Vivado SDK 2018.3 to drive the IP core generated by HLS to realize handwritten digit recognition. Now there is no problem with the result of a single call, but the first result is correct and the subsequent results are wrong when the loop is called multiple times. For example, I recognize the number 0 now, and he is correct. But I recognize multiple pictures in a row, only the first result is correct, and the other results are all wrong, and I need to reprogram the fpga to recognize it correctly. I have checked the input and tested each image individually, and they are all right. What may be the reason? Here are part of my codes:
// 10 * 28 * 28 imgs
float img[10][784]={
#include "./data/0_0.h"
#include "./data/1_0.h"
#include "./data/2_0.h"
#include "./data/3_0.h"
#include "./data/4_0.h"
#include "./data/5_0.h"
#include "./data/6_0.h"
#include "./data/7_0.h"
#include "./data/8_0.h"
#include "./data/9_0.h"
};
int main()
{
init_platform();
Xil_DCacheDisable();
//========= Initialize IP=================
XMylenet mylenet;
XMylenet_Initialize(&mylenet,XPAR_MYLENET_0_DEVICE_ID);
for (int set = 0; set < 10; set++){
//========= input =================
int *img_fixed =(int*)malloc(784*sizeof(int));
int *out =(int*)malloc(10*sizeof(int));
for(int i = 0; i < 784; i++)
img_fixed[i] = 0;
for (int i = 0; i < 10; i++)
out[i] = 0;
for(int i=0;i<784;i++)
img_fixed[i] = img[set][i]*65536;
//========= set IP input output =================
XMylenet_Set_img_in_V(&mylenet,img_fixed);
XMylenet_Set_out_V(&mylenet,out);
//========== start IP =============
XMylenet_Start(&mylenet);
while(XMylenet_IsDone(&mylenet)==0);
//========== print result =============
int max = 0;
int max_index;
for(int i=0;i<10;i++){
float tmp = (float)out[i]/65536.0f;
printf("number %d predicted out: %f\n", i, tmp);
if(tmp>max){
max_index = i;
max = tmp;
}
}
printf("lenet predict out: %d label: %d\n",max_index, set);
free(img_fixed);
free(out);
}
cleanup_platform();
return 0;
}
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now