Skip to content

Commit cf47a6f

Browse files
authored
Fix/user mask overwrite (#63)
2 parents d9ffd26 + abfb55e commit cf47a6f

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

iris/segmentation/static/javascripts/segmentation.js

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,37 +2788,20 @@ async function legacyPredictMask(){
27882788
}
27892789

27902790
const newMaskData = new Uint8Array(currentMaskData);
2791-
const newUserMaskData = new Uint8Array(currentUserMaskData);
2792-
2791+
27932792
// Only update the mask where the user did not draw to
27942793
let aiPixelsApplied = 0;
27952794
for (var i = 0; i < results.data.length; i++) {
27962795
if (!currentUserMaskData[i]){
27972796
newMaskData[i] = results.data[i];
2798-
// CRITICAL: Also mark this pixel as "drawn" in userMask
2799-
// so it gets saved and rendered
2800-
newUserMaskData[i] = 1;
28012797
aiPixelsApplied++;
28022798
}
28032799
}
2804-
2800+
28052801
console.log(`[IRIS] AI Prediction: Applied ${aiPixelsApplied} AI-predicted pixels`);
2806-
2807-
// Update store with prediction results (ONLY SOURCE)
2802+
2803+
// Update store with prediction results
28082804
window.setMaskDataInStore(newMaskData, maskShape[0], maskShape[1]);
2809-
window.setUserMaskDataInStore(newUserMaskData);
2810-
console.log('[IRIS Migration] ✅ Applied prediction results using React store');
2811-
2812-
// Verify the store was updated
2813-
const verifyMaskData = window.getMaskDataFromStore();
2814-
const verifyUserMaskData = window.getUserMaskDataFromStore();
2815-
let verifyAiPixels = 0;
2816-
for (var i = 0; i < verifyMaskData.length; i++) {
2817-
if (verifyUserMaskData[i] === 1 && verifyMaskData[i] !== 0){
2818-
verifyAiPixels++;
2819-
}
2820-
}
2821-
console.log(`[IRIS] AI Prediction: Verified ${verifyAiPixels} total pixels in store after update`);
28222805

28232806
reload_hidden_mask();
28242807
render_mask();

0 commit comments

Comments
 (0)