mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-30 19:33:45 +08:00
1a8dd310ae
* Add support for TinyGrad model runner processing Introduced a new function `is_tinygrad_model` to detect TinyGrad as an active model runner. Updated the `is_stock_model` logic to account for TinyGrad models and added a new process entry for TinyGrad in the model manager. This enables handling TinyGrad models alongside existing configurations. adding modeld back Add support for `modeld_v2` and update paths for consistency Updated `SConscript` files to integrate `modeld_v2` alongside `modeld` and adjusted script paths for correct metadata handling. Adjusted various configurations and scripts, such as `labeler.yaml` and `build_release.sh`, to include `modeld_v2` and ensure cohesive project structure. Refactor imports to use updated `modeld_v2` paths. Replaced outdated `modeld` references with their `modeld_v2` counterparts for consistency and clarity across the codebase. Also updated `.gitignore` to accommodate new directory structure. This change ensures better maintainability and alignment with the new directory schema. Refactor and reorganize modeld to sunnypilot/modeld_v2 structure. Moved and renamed `modeld` components to the new `sunnypilot/modeld_v2` directory for better organization and modularity. Updated imports and file references to align with the new structure, ensuring compatibility and functionality. Streamlined project structure to improve maintainability and future development. * typo * Use `stock` model runner and refactor model checks. Replaces outdated model detection logic with unified `stock` runner integration, simplifying the decision flow for model selection. Includes `stock` as a new enum in the `Runner` type and updates affected references accordingly. * Handle missing 'sim_pose' in model outputs gracefully. Added conditional checks to ensure the code handles cases where 'sim_pose' is absent in the model outputs. Fallback behaviors use 'plan' data when 'sim_pose' is unavailable, preventing potential errors and enhancing robustness.
70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
#include <cassert>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include "tensorflow/c/c_api.h"
|
|
|
|
void* read_file(const char* path, size_t* out_len) {
|
|
FILE* f = fopen(path, "r");
|
|
if (!f) {
|
|
return NULL;
|
|
}
|
|
fseek(f, 0, SEEK_END);
|
|
long f_len = ftell(f);
|
|
rewind(f);
|
|
|
|
char* buf = (char*)calloc(f_len, 1);
|
|
assert(buf);
|
|
|
|
size_t num_read = fread(buf, f_len, 1, f);
|
|
fclose(f);
|
|
|
|
if (num_read != 1) {
|
|
free(buf);
|
|
return NULL;
|
|
}
|
|
|
|
if (out_len) {
|
|
*out_len = f_len;
|
|
}
|
|
|
|
return buf;
|
|
}
|
|
|
|
static void DeallocateBuffer(void* data, size_t) {
|
|
free(data);
|
|
}
|
|
|
|
int main(int argc, char* argv[]) {
|
|
TF_Buffer* buf;
|
|
TF_Graph* graph;
|
|
TF_Status* status;
|
|
char *path = argv[1];
|
|
|
|
// load model
|
|
{
|
|
size_t model_size;
|
|
char tmp[1024];
|
|
snprintf(tmp, sizeof(tmp), "%s.pb", path);
|
|
printf("loading model %s\n", tmp);
|
|
uint8_t *model_data = (uint8_t *)read_file(tmp, &model_size);
|
|
buf = TF_NewBuffer();
|
|
buf->data = model_data;
|
|
buf->length = model_size;
|
|
buf->data_deallocator = DeallocateBuffer;
|
|
printf("loaded model of size %d\n", model_size);
|
|
}
|
|
|
|
// import graph
|
|
status = TF_NewStatus();
|
|
graph = TF_NewGraph();
|
|
TF_ImportGraphDefOptions *opts = TF_NewImportGraphDefOptions();
|
|
TF_GraphImportGraphDef(graph, buf, opts, status);
|
|
TF_DeleteImportGraphDefOptions(opts);
|
|
TF_DeleteBuffer(buf);
|
|
if (TF_GetCode(status) != TF_OK) {
|
|
printf("FAIL: %s\n", TF_Message(status));
|
|
} else {
|
|
printf("SUCCESS\n");
|
|
}
|
|
}
|