Mixed updates and improvements.
This commit is contained in:
1
scripts/.gitignore
vendored
1
scripts/.gitignore
vendored
@ -1 +0,0 @@
|
||||
test_skelda_dataset
|
||||
@ -1,12 +1,12 @@
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// OpenCV
|
||||
#include <opencv2/opencv.hpp>
|
||||
@ -15,10 +15,10 @@
|
||||
#include "/RapidPoseTriangulation/extras/include/nlohmann/json.hpp"
|
||||
using json = nlohmann::json;
|
||||
|
||||
#include "/RapidPoseTriangulation/scripts/utils_pipeline.hpp"
|
||||
#include "/RapidPoseTriangulation/scripts/utils_2d_pose.hpp"
|
||||
#include "/RapidPoseTriangulation/rpt/interface.hpp"
|
||||
#include "/RapidPoseTriangulation/rpt/camera.hpp"
|
||||
#include "/RapidPoseTriangulation/rpt/interface.hpp"
|
||||
#include "/RapidPoseTriangulation/scripts/utils_2d_pose.hpp"
|
||||
#include "/RapidPoseTriangulation/scripts/utils_pipeline.hpp"
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
@ -232,12 +232,12 @@ int main(int argc, char **argv)
|
||||
|
||||
all_poses_3d.push_back(std::move(poses_3d));
|
||||
all_ids.push_back(item["id"].get<std::string>());
|
||||
old_id = item["index"];
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Print timing stats
|
||||
std::cout << "\nMetrics:" << std::endl;
|
||||
tri_model->print_stats();
|
||||
size_t warmup = 10;
|
||||
double avg_time_image = time_image / (time_count - warmup);
|
||||
double avg_time_pose2d = time_pose2d / (time_count - warmup);
|
||||
@ -249,6 +249,7 @@ int main(int argc, char **argv)
|
||||
<< " \"avg_time_3d\": " << avg_time_pose3d << ",\n"
|
||||
<< " \"fps\": " << fps << "\n"
|
||||
<< "}" << std::endl;
|
||||
tri_model->print_stats();
|
||||
|
||||
// Store the results as json
|
||||
json all_results;
|
||||
|
||||
@ -361,7 +361,7 @@ def main():
|
||||
save_json(config, config_path)
|
||||
|
||||
# Call the CPP binary
|
||||
os.system("/RapidPoseTriangulation/scripts/test_skelda_dataset")
|
||||
os.system("/RapidPoseTriangulation/scripts/test_skelda_dataset.bin")
|
||||
|
||||
# Load the results
|
||||
print("Loading exports ...")
|
||||
|
||||
@ -330,7 +330,9 @@ def main():
|
||||
|
||||
# Load 2D pose model
|
||||
if utils_pipeline.use_whole_body(whole_body):
|
||||
kpt_model = utils_2d_pose.load_wb_model(min_bbox_score, min_bbox_area, batch_poses)
|
||||
kpt_model = utils_2d_pose.load_wb_model(
|
||||
min_bbox_score, min_bbox_area, batch_poses
|
||||
)
|
||||
else:
|
||||
kpt_model = utils_2d_pose.load_model(min_bbox_score, min_bbox_area, batch_poses)
|
||||
|
||||
@ -446,10 +448,7 @@ def main():
|
||||
all_ids.append(label["id"])
|
||||
times[i][2] = time_3d
|
||||
|
||||
# Print per-step triangulation timings
|
||||
print("")
|
||||
triangulator.print_stats()
|
||||
|
||||
# Print per-step timings
|
||||
warmup_iters = 10
|
||||
if len(times) > warmup_iters:
|
||||
times = times[warmup_iters:]
|
||||
@ -464,6 +463,7 @@ def main():
|
||||
}
|
||||
print("\nMetrics:")
|
||||
print(json.dumps(tstats, indent=2))
|
||||
triangulator.print_stats()
|
||||
|
||||
_ = evals.mpjpe.run_eval(
|
||||
labels,
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <onnxruntime_cxx_api.h>
|
||||
#include <onnxruntime_c_api.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <tensorrt_provider_options.h>
|
||||
|
||||
// =================================================================================================
|
||||
@ -646,27 +646,10 @@ namespace utils_2d_pose
|
||||
|
||||
std::vector<std::array<float, 5>> RTMDet::call(const cv::Mat &image)
|
||||
{
|
||||
auto stime = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<float> elapsed;
|
||||
|
||||
cv::Mat preprocessed = preprocess(image);
|
||||
std::vector<cv::Mat> inputs = {preprocessed};
|
||||
|
||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
||||
std::cout << "Preprocess time: " << elapsed.count() << "s\n";
|
||||
stime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto results = call_by_image(inputs);
|
||||
|
||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
||||
std::cout << "Inference time: " << elapsed.count() << "s\n";
|
||||
stime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto outputs = postprocess(results, image);
|
||||
|
||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
||||
std::cout << "Postprocess time: " << elapsed.count() << "s\n";
|
||||
|
||||
return outputs;
|
||||
}
|
||||
|
||||
@ -818,26 +801,9 @@ namespace utils_2d_pose
|
||||
std::vector<std::vector<std::array<float, 3>>> RTMPose::call(
|
||||
const cv::Mat &image, const std::vector<std::array<float, 5>> &bboxes)
|
||||
{
|
||||
auto stime = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<float> elapsed;
|
||||
|
||||
std::vector<cv::Mat> inputs = preprocess(image, bboxes);
|
||||
|
||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
||||
std::cout << "Preprocess time: " << elapsed.count() << "s\n";
|
||||
stime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto results = call_by_image(inputs);
|
||||
|
||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
||||
std::cout << "Inference time: " << elapsed.count() << "s\n";
|
||||
stime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto outputs = postprocess(results, image, bboxes);
|
||||
|
||||
elapsed = std::chrono::high_resolution_clock::now() - stime;
|
||||
std::cout << "Postprocess time: " << elapsed.count() << "s\n";
|
||||
|
||||
return outputs;
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ class BaseModel(ABC):
|
||||
raise FileNotFoundError("File not found:", model_path)
|
||||
|
||||
if model_path.endswith(".onnx"):
|
||||
print("Loading model:", model_path)
|
||||
self.init_onnxruntime(model_path)
|
||||
self.runtime = "ort"
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user