Closed SniperPancake closed 2 years ago
Please check and modify the settings in the following lines for your model. https://github.com/iwatake2222/play_with_tensorrt/blob/master/pj_tensorrt_det_yolox/image_processor/detection_engine.cpp#L44 L44 - L50
I tested YOLOX tiny (https://github.com/PINTO0309/PINTO_model_zoo/blob/main/132_YOLOX/download_tiny.sh ), and it worked. However, I didn't test larger models such as YOLOX-m and YOLOX-l. The possibility is that these models need different post-process logic or parameters than YOLOX-tiny, -nano. If you could share your ONNX model, I'll test it. Maybe you can upload (drag&drop) the model here.
Hi, thanks for quick response. I'll look into the code soon. Meanwhile, since models weigh 100 to 200 MB each and I was unable to upload them to github, here is the link to my drive containing these models: https://drive.google.com/drive/folders/1ZOQUw5eoPOA7WtTBYDyP1MIyxupYY6GR?usp=sharing I also uploaded video I was using for testing.
Hi, I got it worked! Please modify detection_engine.cpp
like the followings.
The point is input data normalization. The ONNX model exported from the original repo expects input data in the range of 0 - 255. However, my code uses another model which was converted in a different way and expects input data in the range of around -2.2 - 2.2 (or 0.0 - 1.0).
diff --git a/pj_tensorrt_det_yolox/image_processor/detection_engine.cpp b/pj_tensorrt_det_yolox/image_processor/detection_engine.cpp
index 6f87969..08df8e3 100644
--- a/pj_tensorrt_det_yolox/image_processor/detection_engine.cpp
+++ b/pj_tensorrt_det_yolox/image_processor/detection_engine.cpp
@@ -41,12 +41,12 @@ limitations under the License.
#define PRINT_E(...) COMMON_HELPER_PRINT_E(TAG, __VA_ARGS__)
/* Model parameters */
-#define MODEL_NAME "yolox_nano_480x640.onnx"
+#define MODEL_NAME "yolox_m_736x1280.onnx"
#define TENSORTYPE TensorInfo::kTensorTypeFp32
#define INPUT_NAME "images"
-#define INPUT_DIMS { 1, 3, 480, 640 }
+#define INPUT_DIMS { 1, 3, 736, 1280 }
#define IS_NCHW true
-#define IS_RGB true
+#define IS_RGB false
#define OUTPUT_NAME "output"
static constexpr int32_t kGridScaleList[] = { 8, 16, 32 };
@@ -69,12 +69,12 @@ int32_t DetectionEngine::Initialize(const std::string& work_dir, const int32_t n
InputTensorInfo input_tensor_info(INPUT_NAME, TENSORTYPE, IS_NCHW);
input_tensor_info.tensor_dims = INPUT_DIMS;
input_tensor_info.data_type = InputTensorInfo::kDataTypeImage;
- input_tensor_info.normalize.mean[0] = 0.485f;
- input_tensor_info.normalize.mean[1] = 0.456f;
- input_tensor_info.normalize.mean[2] = 0.406f;
- input_tensor_info.normalize.norm[0] = 0.229f;
- input_tensor_info.normalize.norm[1] = 0.224f;
- input_tensor_info.normalize.norm[2] = 0.225f;
+ input_tensor_info.normalize.mean[0] = 0.0f;
+ input_tensor_info.normalize.mean[1] = 0.0f;
+ input_tensor_info.normalize.mean[2] = 0.0f;
+ input_tensor_info.normalize.norm[0] = 1.0f / 255.0f;
+ input_tensor_info.normalize.norm[1] = 1.0f / 255.0f;
+ input_tensor_info.normalize.norm[2] = 1.0f / 255.0f;
input_tensor_info_list_.push_back(input_tensor_info);
Thank you very much for help! I've checked and it works for me as well!
Project Name
pj_tensorrt_det_yolox
Issue Details
I wanted to use larger YOLOX models (such as YOLOX-m and YOLOX-l) in the project but in result they were unable to detect almost anything. I've used export_onnx.py script included in YOLOX repo (changed the input size to match image size) and had no issues with conversion to .trt format yet the most I achieved was 1 detection each few frames.
Are there any parameters in the project I should consider when using different models?
For comparison here is YOLOX-nano:
And here is YOLOX-m: