diff --git a/Mochi/README.md b/Mochi/README.md index 0c6d96f..8e4d35e 100644 --- a/Mochi/README.md +++ b/Mochi/README.md @@ -87,7 +87,7 @@ train 0 0.11 0.22 0.33 0.44 0.55 0.43 1615255010842 1. Start the Online ML server: `./OrbitAI_Mochi` 2. Send telnet commands to the server: ``` -eval 'input="test_data/camera_tiny.txt"; echo "reset"; while IFS= read -r line; do sleep 0.02; echo "train ${line/+/''} $(date +%s%3N)"; done < "$input";' | telnet localhost 9999 +eval 'input="test_data/camera_tiny.txt"; echo "reset"; while IFS= read -r line; do sleep 0.02; echo "train ${line/+/''} $(date +%s000)"; done < "$input";' | telnet localhost 9999 ``` 3. Monitor a model file being updated: `watch -n 0.1 cat models/arow_2D` @@ -103,7 +103,7 @@ eval 'input="test_data/camera_tiny.txt"; echo "reset"; while IFS= read -r line; 1. Start the Online ML server: `./OrbitAI_Mochi` 2. Send telnet commands to the server: ``` -eval 'echo "load"; sleep 1; input="test_data/camera_tiny.txt"; while IFS= read -r line; do sleep 0.02; echo "infer ${line/+/''} $(date +%s%3N)"; done < "$input";' | telnet localhost 9999 +eval 'echo "load"; sleep 1; input="test_data/camera_tiny.txt"; while IFS= read -r line; do sleep 0.02; echo "infer ${line/+/''} $(date +%s000)"; done < "$input";' | telnet localhost 9999 ``` ### Validation @@ -111,7 +111,7 @@ As a pre-requisite, make sure that `src/OrbitAI_Mochi.cpp` is compiled with the 1. Start the Online ML server: `./OrbitAI_Mochi` 2. Delete any previously saved models and log files followed by training and infering test data: ``` -eval 'echo "reset"; sleep 1; input="test_data/camera_train_and_infer_small.txt"; while IFS= read -r line; do sleep 0.02; echo "${line/+/''} $(date +%s%3N)"; done < "$input";' | telnet localhost 9999 +eval 'echo "reset"; sleep 1; input="test_data/camera_train_and_infer_small.txt"; while IFS= read -r line; do sleep 0.02; echo "${line/+/''} $(date +%s000)"; done < "$input";' | telnet localhost 9999 ``` 3. Rename the `logs/training.csv` file to `logs/training1.csv` so the logged trianing data is not lost the next time that the `reset` command is invoked: `mv logs/training.csv logs/training1.csv` 4. Rename the `logs/inference.csv` file to `logs/inference1.csv` so the logged inference results are not lost the next time that the `reset` command is invoked: `mv logs/inference.csv logs/inference1.csv` @@ -120,7 +120,7 @@ Retrain the models from scratch but this time skip the inference: 1. Start the Online ML server: `./OrbitAI_Mochi` 2. Train and save the models: ``` -eval 'echo "reset"; sleep 1; input="test_data/camera_small.txt"; while IFS= read -r line; do sleep 0.02; echo "train ${line/+/''} $(date +%s%3N)"; done < "$input";' | telnet localhost 9999 +eval 'echo "reset"; sleep 1; input="test_data/camera_small.txt"; while IFS= read -r line; do sleep 0.02; echo "train ${line/+/''} $(date +%s000)"; done < "$input";' | telnet localhost 9999 ``` 3. Diff `logs/training1.csv` and `logs/training.csv`. Both files should be exactly the same: `diff logs/training1.csv logs/training.csv` @@ -128,7 +128,7 @@ Load the saved models and infer given validation inputs. The inference results w 1. Start the Online ML server: `./OrbitAI_Mochi` 2. Load saved models and infer: ``` -eval 'echo "load"; sleep 1; input="test_data/camera_validation_small.txt"; while IFS= read -r line; do sleep 0.02; echo "infer ${line/+/''} $(date +%s%3N)"; done < "$input";' | telnet localhost 9999 +eval 'echo "load"; sleep 1; input="test_data/camera_validation_small.txt"; while IFS= read -r line; do sleep 0.02; echo "infer ${line/+/''} $(date +%s000)"; done < "$input";' | telnet localhost 9999 ``` 3. Diff `logs/inference1.csv` and `logs/inference.csv`. Both files should be exactly the same: `diff logs/inference1.csv logs/inference.csv` diff --git a/Mochi/src/OrbitAI_Mochi.cpp b/Mochi/src/OrbitAI_Mochi.cpp index a0e1ba6..ee85fa7 100644 --- a/Mochi/src/OrbitAI_Mochi.cpp +++ b/Mochi/src/OrbitAI_Mochi.cpp @@ -582,7 +582,7 @@ int main(int argc, char *argv[]) { /** * Expected command string format: - * train + * train * * e.g.: * train 1 0.11 0.22 0.33 0.44 0.55 1.23 1615253200322 @@ -611,7 +611,9 @@ int main(int argc, char *argv[]) float pd6 = std::stof(cmdTokens[7]); // PD acquisition timestamp. - long timestamp = std::stol(cmdTokens[8]); + // A long in SEPP's ARM architecture is 32 bit so it can't fit the timestamp in ms. + // Use a string instead (we only use this value for logging). + std::string timestamp = cmdTokens[8]; // Training input error. if(!(label == 0 || label == -1 || label == 1)) @@ -953,7 +955,7 @@ int main(int argc, char *argv[]) // Creating the training row string to append to the log file. std::string trainingLogFileRow = #if LOG_TIMES - std::to_string(timestamp) + "," + + timestamp + "," + #endif std::to_string(pd1) + "," + std::to_string(pd2) + "," + std::to_string(pd3) + "," + std::to_string(pd4) + "," + std::to_string(pd5) + "," + std::to_string(pd6) + "," + std::to_string(label) #if LOG_TIMES @@ -995,7 +997,7 @@ int main(int argc, char *argv[]) { /** * Expected command string format: - * infer + * infer * * e.g.: * infer +1 0.11 0.22 0.33 0.44 0.55 1.23 1615253200322 @@ -1025,7 +1027,9 @@ int main(int argc, char *argv[]) float pd6 = std::stof(cmdTokens[7]); // PD acquisition timestamp. - long timestamp = std::stol(cmdTokens[8]); + // A long in SEPP's ARM architecture is 32 bit so it can't fit the timestamp in ms. + // Use a string instead (we only use this value for logging). + std::string timestamp = cmdTokens[8]; // inference input error. if(!(label == 0 || label == -1 || label == 1)) @@ -1280,7 +1284,7 @@ int main(int argc, char *argv[]) // Creating the inference results row string to append to the log file. std::string inferenceLogFileRow = #if LOG_TIMES - std::to_string(timestamp) + "," + + timestamp + "," + #endif std::to_string(pd1) + "," + std::to_string(pd2) + "," + std::to_string(pd3) + "," + std::to_string(pd4) + "," + std::to_string(pd5) + "," + std::to_string(pd6) + "," + std::to_string(label) + "," + predictions