Rolling 20210910

This commit is contained in:
jomjol
2021-09-10 09:26:52 +02:00
parent af99de3535
commit dd995ec28a
27 changed files with 820 additions and 1097 deletions

View File

@@ -28,6 +28,48 @@ int CTfLiteClass::GetClassFromImageBasis(CImageBasis *rs)
return GetOutClassification();
}
int CTfLiteClass::GetOutClassification(int _von, int _bis)
{
TfLiteTensor* output2 = interpreter->output(0);
float zw_max;
float zw;
int zw_class;
if (output2 == NULL)
return -1;
int numeroutput = output2->dims->data[1];
//printf("\n number output neurons: %d\n\n", numeroutput);
if (_bis == -1)
_bis = numeroutput;
if (_von == -1)
_von = 0;
if (_bis > numeroutput)
{
printf("ANZAHL OUTPUT NEURONS passt nicht zu geforderter Classifizierung!");
return -1;
}
zw_max = output2->data.f[_von];
zw_class = _von;
for (int i = _von+1; i <= _bis; ++i)
{
zw = output2->data.f[i];
if (zw > zw_max)
{
zw_max = zw;
zw_class = i;
}
}
return (zw_class - _von);
}
/*
int CTfLiteClass::GetOutClassification()
{
TfLiteTensor* output2 = interpreter->output(0);
@@ -51,6 +93,7 @@ int CTfLiteClass::GetOutClassification()
}
return zw_class;
}
*/
void CTfLiteClass::GetInputDimension(bool silent = false)
{
@@ -71,18 +114,18 @@ void CTfLiteClass::GetInputDimension(bool silent = false)
}
void CTfLiteClass::GetOutPut()
int CTfLiteClass::GetAnzOutPut(bool silent)
{
TfLiteTensor* output2 = this->interpreter->output(0);
int numdim = output2->dims->size;
printf("NumDimension: %d\n", numdim);
if (!silent) printf("NumDimension: %d\n", numdim);
int sizeofdim;
for (int j = 0; j < numdim; ++j)
{
sizeofdim = output2->dims->data[j];
printf("SizeOfDimension %d: %d\n", j, sizeofdim);
if (!silent) printf("SizeOfDimension %d: %d\n", j, sizeofdim);
}
@@ -93,8 +136,9 @@ void CTfLiteClass::GetOutPut()
for (int i = 0; i < numeroutput; ++i)
{
fo = output2->data.f[i];
printf("Result %d: %f\n", i, fo);
if (!silent) printf("Result %d: %f\n", i, fo);
}
return numeroutput;
}
void CTfLiteClass::Invoke()
@@ -107,7 +151,7 @@ void CTfLiteClass::Invoke()
bool CTfLiteClass::LoadInputImageBasis(CImageBasis *rs)
{
std::string zw = "ClassFlowAnalog::doNeuralNetwork nach LoadInputResizeImage: ";
std::string zw = "ClassFlowCNNGeneral::doNeuralNetwork nach LoadInputResizeImage: ";
unsigned int w = rs->width;
unsigned int h = rs->height;

View File

@@ -61,8 +61,11 @@ class CTfLiteClass
void GetInputTensorSize();
bool LoadInputImageBasis(CImageBasis *rs);
void Invoke();
void GetOutPut();
int GetOutClassification();
int GetAnzOutPut(bool silent = true);
// void GetOutPut();
// int GetOutClassification();
int GetOutClassification(int _von = -1, int _bis = -1);
int GetClassFromImageBasis(CImageBasis *rs);
std::string GetStatusFlow();

View File

@@ -284,16 +284,27 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
httpd_resp_sendstr_chunk(req, txt.c_str());
std::vector<HTMLInfo*> htmlinfo;
htmlinfo = tfliteflow.GetAllDigital();
htmlinfo = tfliteflow.GetAllDigital();
printf("Size of htmlinfo: %i\n", htmlinfo.size());
for (int i = 0; i < htmlinfo.size(); ++i)
{
if (htmlinfo[i]->val == 10)
zw = "NaN";
if (tfliteflow.GetTypeDigital() == Digital)
{
if (htmlinfo[i]->val == 10)
zw = "NaN";
else
zw = to_string((int) htmlinfo[i]->val);
txt = "<img src=\"/img_tmp/" + htmlinfo[i]->filename + "\"> " + zw;
}
else
{
zw = to_string((int) htmlinfo[i]->val);
std::stringstream stream;
stream << std::fixed << std::setprecision(1) << htmlinfo[i]->val;
zw = stream.str();
txt = "<img src=\"/img_tmp/" + htmlinfo[i]->filename + "\"> " + zw;
}
txt = "<img src=\"/img_tmp/" + htmlinfo[i]->filename + "\"> " + zw;
httpd_resp_sendstr_chunk(req, txt.c_str());
delete htmlinfo[i];
}
@@ -493,7 +504,9 @@ esp_err_t handler_editflow(httpd_req_t *req)
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
std::string zw = tfliteflow.doSingleStep("[Alignment]", _host);
httpd_resp_sendstr_chunk(req, zw.c_str());
}
}
/*
if (_task.compare("test_analog") == 0)
{
std::string _host = "";
@@ -504,7 +517,9 @@ esp_err_t handler_editflow(httpd_req_t *req)
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
std::string zw = tfliteflow.doSingleStep("[Analog]", _host);
httpd_resp_sendstr_chunk(req, zw.c_str());
}
}
*/
/*
if (_task.compare("test_digits") == 0)
{
std::string _host = "";
@@ -517,6 +532,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
std::string zw = tfliteflow.doSingleStep("[Digits]", _host);
httpd_resp_sendstr_chunk(req, zw.c_str());
}
*/
/* Respond with an empty chunk to signal HTTP response completion */