mirror of
https://github.com/azaion/detections.git
synced 2026-04-22 11:16:31 +00:00
Refactor type casting in Cython files for improved clarity and consistency
- Updated various Cython files to explicitly cast types, enhancing type safety and readability. - Adjusted the `engine_name` property in `InferenceEngine` and its subclasses to be set directly in the constructor. - Modified the `request` method in `_SessionWithBase` to accept `*args` for better flexibility. - Ensured proper type casting for return values in methods across multiple classes, including `Inference`, `CoreMLEngine`, and `TensorRTEngine`. These changes aim to streamline the codebase and improve maintainability by enforcing consistent type usage.
This commit is contained in:
@@ -36,15 +36,15 @@ cdef class OnnxEngine(InferenceEngine):
|
||||
|
||||
cdef tuple get_input_shape(self):
|
||||
shape = self.input_shape
|
||||
return shape[2], shape[3]
|
||||
return <tuple>(shape[2], shape[3])
|
||||
|
||||
cdef int get_batch_size(self):
|
||||
return self.batch_size
|
||||
return <int>self.batch_size
|
||||
|
||||
cdef run(self, input_data):
|
||||
try:
|
||||
return self.session.run(None, {self.input_name: input_data})
|
||||
return self.session.run(None, {self.input_name: input_data}) # type: ignore[attr-defined]
|
||||
except Exception:
|
||||
if self._cpu_session is not None:
|
||||
return self._cpu_session.run(None, {self.input_name: input_data})
|
||||
return self._cpu_session.run(None, {self.input_name: input_data}) # type: ignore[attr-defined]
|
||||
raise
|
||||
Reference in New Issue
Block a user