fix: Change the structure of builder
This commit is contained in:
@@ -56,9 +56,10 @@ impl FaceDetectionBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FaceDetection {
|
impl FaceDetection {
|
||||||
pub fn builder<T: AsRef<[u8]>>()
|
pub fn builder<T: AsRef<[u8]>>(
|
||||||
-> fn(T) -> std::result::Result<FaceDetectionBuilder, Report<Error>> {
|
model: T,
|
||||||
FaceDetectionBuilder::new
|
) -> std::result::Result<FaceDetectionBuilder, error_stack::Report<crate::errors::Error>> {
|
||||||
|
FaceDetectionBuilder::new(model)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(path: impl AsRef<Path>) -> Result<Self> {
|
pub fn new(path: impl AsRef<Path>) -> Result<Self> {
|
||||||
|
|||||||
@@ -119,10 +119,10 @@ impl FaceDetectionBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FaceDetection {
|
impl FaceDetection {
|
||||||
pub fn builder<T: AsRef<[u8]>>()
|
pub fn builder<T: AsRef<[u8]>>(
|
||||||
-> fn(T) -> std::result::Result<FaceDetectionBuilder, error_stack::Report<crate::errors::Error>>
|
model: T,
|
||||||
{
|
) -> std::result::Result<FaceDetectionBuilder, error_stack::Report<crate::errors::Error>> {
|
||||||
FaceDetectionBuilder::new
|
FaceDetectionBuilder::new(model)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(path: impl AsRef<Path>) -> crate::errors::Result<Self> {
|
pub fn new(path: impl AsRef<Path>) -> crate::errors::Result<Self> {
|
||||||
@@ -134,7 +134,7 @@ impl FaceDetection {
|
|||||||
|
|
||||||
pub fn new_from_bytes(model: &[u8]) -> crate::errors::Result<Self> {
|
pub fn new_from_bytes(model: &[u8]) -> crate::errors::Result<Self> {
|
||||||
tracing::info!("Loading ORT RetinaFace model from bytes");
|
tracing::info!("Loading ORT RetinaFace model from bytes");
|
||||||
Self::builder()(model)?.build()
|
Self::builder(model)?.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ pub fn main() -> Result<()> {
|
|||||||
match executor {
|
match executor {
|
||||||
cli::Executor::Mnn => {
|
cli::Executor::Mnn => {
|
||||||
let retinaface =
|
let retinaface =
|
||||||
facedet::retinaface::mnn::FaceDetection::builder()(RETINAFACE_MODEL_MNN)
|
facedet::retinaface::mnn::FaceDetection::builder(RETINAFACE_MODEL_MNN)
|
||||||
.change_context(Error)?
|
.change_context(Error)?
|
||||||
.with_forward_type(detect.forward_type)
|
.with_forward_type(detect.forward_type)
|
||||||
.build()
|
.build()
|
||||||
@@ -45,7 +45,7 @@ pub fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
cli::Executor::Onnx => {
|
cli::Executor::Onnx => {
|
||||||
let retinaface =
|
let retinaface =
|
||||||
facedet::retinaface::ort::FaceDetection::builder()(RETINAFACE_MODEL_ONNX)
|
facedet::retinaface::ort::FaceDetection::builder(RETINAFACE_MODEL_ONNX)
|
||||||
.change_context(Error)?
|
.change_context(Error)?
|
||||||
.build()
|
.build()
|
||||||
.change_context(errors::Error)
|
.change_context(errors::Error)
|
||||||
|
|||||||
Reference in New Issue
Block a user