remove cpdef, add constants h

This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-08-12 14:53:14 +03:00
parent ad782bcbaa
commit 9e4dc5404c
6 changed files with 68 additions and 13 deletions
+55
View File
@@ -0,0 +1,55 @@
/* Generated by Cython 3.1.2 */
#ifndef __PYX_HAVE__constants_inf
#define __PYX_HAVE__constants_inf
#include "Python.h"
#ifndef __PYX_HAVE_API__constants_inf
#ifdef CYTHON_EXTERN_C
#undef __PYX_EXTERN_C
#define __PYX_EXTERN_C CYTHON_EXTERN_C
#elif defined(__PYX_EXTERN_C)
#ifdef _MSC_VER
#pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.")
#else
#warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.
#endif
#else
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#endif
#ifndef DL_IMPORT
#define DL_IMPORT(_T) _T
#endif
__PYX_EXTERN_C int TILE_DUPLICATE_CONFIDENCE_THRESHOLD;
#endif /* !__PYX_HAVE_API__constants_inf */
/* WARNING: the interface of the module init function changed in CPython 3.5. */
/* It now returns a PyModuleDef instance instead of a PyModule instance. */
/* WARNING: Use PyImport_AppendInittab("constants_inf", PyInit_constants_inf) instead of calling PyInit_constants_inf directly from Python 3.5 */
PyMODINIT_FUNC PyInit_constants_inf(void);
#if PY_VERSION_HEX >= 0x03050000 && (defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) || (defined(__cplusplus) && __cplusplus >= 201402L))
#if defined(__cplusplus) && __cplusplus >= 201402L
[[deprecated("Use PyImport_AppendInittab(\"constants_inf\", PyInit_constants_inf) instead of calling PyInit_constants_inf directly.")]] inline
#elif defined(__GNUC__) || defined(__clang__)
__attribute__ ((__deprecated__("Use PyImport_AppendInittab(\"constants_inf\", PyInit_constants_inf) instead of calling PyInit_constants_inf directly."), __unused__)) __inline__
#elif defined(_MSC_VER)
__declspec(deprecated("Use PyImport_AppendInittab(\"constants_inf\", PyInit_constants_inf) instead of calling PyInit_constants_inf directly.")) __inline
#endif
static PyObject* __PYX_WARN_IF_PyInit_constants_inf_INIT_CALLED(PyObject* res) {
return res;
}
#define PyInit_constants_inf() __PYX_WARN_IF_PyInit_constants_inf_INIT_CALLED(PyInit_constants_inf())
#endif
#endif /* !__PYX_HAVE__constants_inf */
+2 -2
View File
@@ -20,7 +20,7 @@ cdef class Inference:
cdef int tile_height
cdef build_tensor_engine(self, object updater_callback)
cpdef init_ai(self)
cdef init_ai(self)
cdef bint is_building_engine
cdef bint is_video(self, str filepath)
@@ -28,7 +28,7 @@ cdef class Inference:
cdef _process_video(self, RemoteCommand cmd, AIRecognitionConfig ai_config, str video_name)
cdef _process_images(self, RemoteCommand cmd, AIRecognitionConfig ai_config, list[str] image_paths)
cdef _process_images_inner(self, RemoteCommand cmd, AIRecognitionConfig ai_config, list frame_data)
cpdef split_to_tiles(self, frame, path, overlap_percent)
cdef split_to_tiles(self, frame, path, overlap_percent)
cdef stop(self)
cdef preprocess(self, frames)
+2 -2
View File
@@ -97,7 +97,7 @@ cdef class Inference:
except Exception as e:
updater_callback(f'Error. {str(e)}')
cpdef init_ai(self):
cdef init_ai(self):
if self.engine is not None:
return
@@ -292,7 +292,7 @@ cdef class Inference:
self._process_images_inner(cmd, ai_config, chunk)
cpdef split_to_tiles(self, frame, path, overlap_percent):
cdef split_to_tiles(self, frame, path, overlap_percent):
constants_inf.log(<str>f'splitting image {path} to tiles...')
img_h, img_w, _ = frame.shape
stride_w = int(self.tile_width * (1 - overlap_percent / 100))
+3 -3
View File
@@ -15,12 +15,12 @@ cdef class OnnxEngine(InferenceEngine):
model_meta = self.session.get_modelmeta()
constants_inf.log(f"Metadata: {model_meta.custom_metadata_map}")
cpdef tuple get_input_shape(self):
cdef tuple get_input_shape(self):
shape = self.input_shape
return shape[2], shape[3]
cpdef int get_batch_size(self):
cdef int get_batch_size(self):
return self.batch_size
cpdef run(self, input_data):
cdef run(self, input_data):
return self.session.run(None, {self.input_name: input_data})
+3 -3
View File
@@ -17,8 +17,8 @@ cdef class TensorRTEngine(InferenceEngine):
cdef object stream
cpdef tuple get_input_shape(self)
cdef tuple get_input_shape(self)
cpdef int get_batch_size(self)
cdef int get_batch_size(self)
cpdef run(self, input_data)
cdef run(self, input_data)
+3 -3
View File
@@ -112,13 +112,13 @@ cdef class TensorRTEngine(InferenceEngine):
constants_inf.log('conversion done!')
return bytes(plan)
cpdef tuple get_input_shape(self):
cdef tuple get_input_shape(self):
return self.input_shape[2], self.input_shape[3]
cpdef int get_batch_size(self):
cdef int get_batch_size(self):
return self.batch_size
cpdef run(self, input_data):
cdef run(self, input_data):
try:
cuda.memcpy_htod_async(self.d_input, input_data, self.stream)
self.context.set_tensor_address(self.input_name, int(self.d_input)) # input buffer