mirror of
https://github.com/huggingface/candle.git
synced 2025-06-16 10:38:54 +00:00
Return the low res mask in the wasm segment-anything module. (#798)
* Return the low res mask. * Add some validations.
This commit is contained in:
@ -77,8 +77,18 @@ impl Model {
|
||||
|
||||
// x and y have to be between 0 and 1
|
||||
pub fn mask_for_point(&self, x: f64, y: f64) -> Result<String, JsError> {
|
||||
if !(0. ..=1.).contains(&x) {
|
||||
Err(JsError::new(&format!(
|
||||
"x has to be between 0 and 1, got {x}"
|
||||
)))?
|
||||
}
|
||||
if !(0. ..=1.).contains(&y) {
|
||||
Err(JsError::new(&format!(
|
||||
"y has to be between 0 and 1, got {y}"
|
||||
)))?
|
||||
}
|
||||
let embeddings = match &self.embeddings {
|
||||
None => todo!(),
|
||||
None => Err(JsError::new("image embeddings have not been set"))?,
|
||||
Some(embeddings) => embeddings,
|
||||
};
|
||||
let (mask, iou_predictions) = self.sam.forward_for_embeddings(
|
||||
|
Reference in New Issue
Block a user