File size: 855 Bytes
ed9f15f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**

 * YOLO Detection - Detect and crop embryos

 */

import { getModel } from '../state.js';
import { DETECTION_CONFIG } from '../config.js';
import { preprocessImageYOLO } from '../processing/imagePreprocessing.js';
import { postprocessYOLO } from '../processing/yoloPostprocessing.js';
import { loadImage } from '../utils/imageUtils.js';

/**

 * Detect embryos using YOLO

 */
export async function detectEmbryos(imageData) {
    const img = await loadImage(imageData);
    const inputTensor = await preprocessImageYOLO(img, DETECTION_CONFIG.yolo.inputSize);
    
    const feeds = { images: inputTensor };
    const results = await getModel('yolo').run(feeds);
    
    return postprocessYOLO(results, img);
}

/**

 * Check if YOLO model is available

 */
export function isYOLOAvailable() {
    return !!getModel('yolo');
}