移植c_cnn代码

This commit is contained in:
Qiea
2024-11-11 18:17:48 +08:00
parent 88ab12182e
commit 8d49d67929
4 changed files with 292 additions and 709 deletions

View File

@@ -138,7 +138,7 @@ u8 modelmym_free(char* model_name){
modelmym_free("data");
return 2;
}
return NULL;
return 0;
}
@@ -166,13 +166,14 @@ u8 model_write(char* model_name)
u32 _larr = 0;
u8 _len = strlen(model_name);
char _path[_len+1+7+30];
char _datapath[_len+1+7+30];
char _fstr[READLENGTH+1] = {0};
char _sstr[2];
int progress;
Model *_model = model(model_name);
if(_model == NULL || strcmp(model_name, "data") == 0){
sprintf(_path, "0:/%s.txt", model_name);
sprintf(_path, "0:/dataset/_data/%s.txt", model_name);
if(f_open(file, (const TCHAR *)_path, 1)){
DEBUG_PRINTF("\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>ģ<EFBFBD>ͻ<EFBFBD>Data<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n");
return 199;
@@ -183,8 +184,8 @@ u8 model_write(char* model_name)
}
if(_model -> dname == NULL){
sprintf(_path, "0:/%s.txt", _model -> name);
if(f_open(file, (TCHAR *)_path, 1)){
sprintf(_path, "0:/dataset/%s.txt", _model -> name);
if(f_open(file, (const TCHAR *)_path, 1)){
DEBUG_PRINTF("Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>ͣ<EFBFBD>[%s]\r\n", _path);
return 4;
}
@@ -195,6 +196,13 @@ u8 model_write(char* model_name)
return 200;
}
if(_model -> dname)sprintf(_datapath, "_data/%s", _model -> dname);
sprintf(_path, "0:/dataset/%s.txt", _model -> dname ? _datapath : _model -> name);
if(f_open(file, (const TCHAR *)_path, 1)){
DEBUG_PRINTF("<EFBFBD>ļ<EFBFBD>[%s]<5D>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>\r\n", _model -> dname ? _model -> dname : _model -> name);
return 199;
}
DEBUG_PRINTF("д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>Ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>%s\r\n", _model -> name);
if(_model -> dname)DEBUG_PRINTF("д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Data<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD>ǣ<EFBFBD>%s\r\n", _model -> dname);
DEBUG_PRINTF("д<EFBFBD><EFBFBD>ģ<EFBFBD>Ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󳤶<EFBFBD>Ϊ<EFBFBD><EFBFBD>%d\r\n", _model -> maxlength);
@@ -239,9 +247,9 @@ u8 model_write(char* model_name)
}
}
DEBUG_PRINTF("\r\nģ<EFBFBD>Ͳ<EFBFBD><EFBFBD><EFBFBD>[%s]<5D><>д<EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>! ģ<>ͳ<EFBFBD><CDB3><EFBFBD>Ϊ %d\r\n",_model -> dname ? _model -> dname : _model -> name,_model -> realength);
return 1;
return 0;
}
return NULL;
return 1;
}
@@ -269,7 +277,7 @@ u8 model_read(char* model_name, u32 start, u32 end, u32 gap){
return 1;
}
}
return NULL;
return 0;
}
@@ -278,17 +286,17 @@ u8 model_switchdata(char* data_name){
u8 _len = strlen(data_name);
char _path[_len+1+7];
if(data.array != NULL)modelmym_free("data");
sprintf(_path, "0:/%s.txt",data_name);
sprintf(_path, "0:/dataset/_data/%s.txt",data_name);
if(f_open(file,(const TCHAR*)_path,1)){
DEBUG_PRINTF("\r\nData<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>[%s]<5D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n",data_name);
return NULL;
return 0;
}else{
u8 _res = model_write(data_name);
if (_res == NULL) {
if (_res) {
DEBUG_PRINTF("Data<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>[%s]<5D>л<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>\r\n",data_name);
return NULL;
return 0;
}
else printf("Data<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>[%s]<5D>л<EFBFBD><D0BB>ɹ<EFBFBD><C9B9><EFBFBD>\r\n",data_name);
else DEBUG_PRINTF("Data<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>[%s]<5D>л<EFBFBD><D0BB>ɹ<EFBFBD><C9B9><EFBFBD>\r\n",data_name);
DEBUG_PRINTF("data_name<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>%d\r\n_path<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>%d\r\n_pathΪ<EFBFBD><EFBFBD>%s\r\n",_len,sizeof(_path),_path);
return 1;
}
@@ -321,7 +329,7 @@ u8 model_info(char* model_name){
//if(strcmp(_model -> name, "data") == 0)printf("dataset is: %s\r\n",_model -> dname); <20><EFBFBD><E2BAAF><EFBFBD><EFBFBD>BUG<55><47><EFBFBD><EFBFBD>model_dataset<65><74><EFBFBD><EFBFBD>
return 1;
}
return NULL;
return 0;
}
@@ -352,6 +360,8 @@ void model_init(){
conv1_weight.name = "conv1_weight";
conv1_weight.array = modelmym_init(conv1_weight.name);
conv1_weight.maxlength = CONV1_WEIGHT_ARRSIZE;
conv1_weight.channel = 1;
conv1_weight.num_kernels = 32;
conv2_bias.name = "conv2_bias";
conv2_bias.array = modelmym_init(conv2_bias.name);
@@ -360,6 +370,8 @@ void model_init(){
conv2_weight.name = "conv2_weight";
conv2_weight.array = modelmym_init(conv2_weight.name);
conv2_weight.maxlength = CONV2_WEIGHT_ARRSIZE;
conv2_weight.channel = 32;
conv2_weight.num_kernels = 64;
conv3_bias.name = "conv3_bias";
conv3_bias.array = modelmym_init(conv3_bias.name);
@@ -368,6 +380,8 @@ void model_init(){
conv3_weight.name = "conv3_weight";
conv3_weight.array = modelmym_init(conv3_weight.name);
conv3_weight.maxlength = CONV3_WEIGHT_ARRSIZE;
conv3_weight.channel = 64;
conv3_weight.num_kernels = 128;
fc1_bias.name = "fc1_bias";
fc1_bias.array = modelmym_init(fc1_bias.name);