Skip to content

Commit

Permalink
feat(demo): add time profile (#2307)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisonooo committed Aug 2, 2023
1 parent 50df685 commit c1bfccd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
9 changes: 8 additions & 1 deletion demo/csrc/cpp/classifier.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ int main(int argc, char* argv[]) {
return -1;
}

mmdeploy::Profiler profiler("/tmp/profile.bin");
mmdeploy::Context context;
context.Add(mmdeploy::Device(FLAGS_device));
context.Add(profiler);

// construct a classifier instance
mmdeploy::Classifier classifier(mmdeploy::Model{ARGS_model}, mmdeploy::Device{FLAGS_device});
mmdeploy::Classifier classifier(mmdeploy::Model{ARGS_model}, context);



// apply the classifier; the result is an array-like class holding references to
// `mmdeploy_classification_t`, will be released automatically on destruction
Expand Down
6 changes: 5 additions & 1 deletion demo/csrc/cpp/detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "failed to load image: %s\n", ARGS_image.c_str());
return -1;
}
mmdeploy::Profiler profiler("/tmp/profile.bin");
mmdeploy::Context context;
context.Add(mmdeploy::Device(FLAGS_device));
context.Add(profiler);

// construct a detector instance
mmdeploy::Detector detector(mmdeploy::Model{ARGS_model}, mmdeploy::Device{FLAGS_device});
mmdeploy::Detector detector(mmdeploy::Model{ARGS_model}, context);

// apply the detector, the result is an array-like class holding references to
// `mmdeploy_detection_t`, will be released automatically on destruction
Expand Down
7 changes: 6 additions & 1 deletion demo/csrc/cpp/pose_detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ int main(int argc, char *argv[]) {

using namespace mmdeploy;

PoseDetector detector{Model(model_path), Device(device_name)};
mmdeploy::Profiler profiler("/tmp/profile.bin");
mmdeploy::Context context;
context.Add(mmdeploy::Device(device_name));
context.Add(profiler);

PoseDetector detector{Model(model_path), context};
auto res = detector.Apply(img);

for (int i = 0; i < res[0].length; i++) {
Expand Down
7 changes: 6 additions & 1 deletion demo/csrc/cpp/restorer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ int main(int argc, char* argv[]) {
return -1;
}

mmdeploy::Profiler profiler("/tmp/profile.bin");
mmdeploy::Context context;
context.Add(mmdeploy::Device(FLAGS_device));
context.Add(profiler);

// construct a restorer instance
mmdeploy::Restorer restorer{mmdeploy::Model{ARGS_model}, mmdeploy::Device{FLAGS_device}};
mmdeploy::Restorer restorer{mmdeploy::Model{ARGS_model}, context};

// apply restorer to the image
mmdeploy::Restorer::Result result = restorer.Apply(img);
Expand Down
7 changes: 6 additions & 1 deletion demo/csrc/cpp/rotated_detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ int main(int argc, char* argv[]) {
return -1;
}

mmdeploy::Profiler profiler("/tmp/profile.bin");
mmdeploy::Context context;
context.Add(mmdeploy::Device(FLAGS_device));
context.Add(profiler);

// construct a detector instance
mmdeploy::RotatedDetector detector(mmdeploy::Model{ARGS_model}, mmdeploy::Device{FLAGS_device});
mmdeploy::RotatedDetector detector(mmdeploy::Model{ARGS_model}, context);

// apply the detector, the result is an array-like class holding references to
// `mmdeploy_rotated_detection_t`, will be released automatically on destruction
Expand Down
6 changes: 5 additions & 1 deletion demo/csrc/cpp/segmentor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ int main(int argc, char* argv[]) {
return -1;
}

mmdeploy::Segmentor segmentor{mmdeploy::Model{ARGS_model}, mmdeploy::Device{FLAGS_device}};
mmdeploy::Profiler profiler("/tmp/profile.bin");
mmdeploy::Context context;
context.Add(mmdeploy::Device(FLAGS_device));
context.Add(profiler);
mmdeploy::Segmentor segmentor{mmdeploy::Model{ARGS_model}, context};

// apply the detector, the result is an array-like class holding a reference to
// `mmdeploy_segmentation_t`, will be released automatically on destruction
Expand Down

0 comments on commit c1bfccd

Please sign in to comment.