dermy-api/src/model.rs

31 lines
767 B
Rust
Raw Normal View History

2024-06-08 15:36:06 +00:00
use axum::{
body::Body,
response::Response
};
use crate::ApiResult;
use pyo3::prelude::*;
const MODULE: &str = include_str!("model/model.py");
const MODEL: &[u8] = include_bytes!("model/model.keras");
2024-06-06 18:21:12 +00:00
pub fn router() -> axum::Router {
axum::Router::new()
.route("/",
axum::routing::post(get_predict)
)
}
2024-06-08 15:36:06 +00:00
async fn get_predict() -> ApiResult {
//TODO: If api key is correct
// Extract image from body of req
let result = Python::with_gil(|py| -> PyResult<()> {
let predict: Py<PyAny> = PyModule::from_code_bound(py, MODULE, "model.py", "model")?
.getattr("predict")?.into();
2024-06-09 17:22:13 +00:00
//TODO: Get result and return it
2024-06-08 15:36:06 +00:00
Ok(())
});
Ok(Response::builder().body(Body::from(""))?)
}