BUG: Face clusters doesnot disappear even after removing folder and clicking recluster faces
Is there an existing issue for this?
- [x] I have searched the existing issues
What happened?
This issue deals with multiple bugs
- Face clustering doesnot start automatically when uploaded folder and clicked AI tagging
- Clustered face groups do not disappear after removing the folder
- Clustered face groups do not disappear even after clicking recluster facea after deleting the folder
How to reproduce
- Upload a folder with human faces
- Click AI tagging
- Go to AI tagging -> you will see no clustered faces
- Go back to settings and click recluster faces -> go to AI tagging -> you will see clustered faces
- Remove the folder -> go to AI tagging -> you will still see clustered faces
- Click recluster faces -> go to AI tagging -> you will still see clustered faces
https://github.com/user-attachments/assets/c2bf7369-5ad5-4be0-904c-e73cad958390
I would like to work on this issue
Record
- [x] I agree to follow this project's Code of Conduct
👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)
I would like to work on this issue
Hi @DeveloperAmrit, are you still working on this issue? I noticed there hasn't been an update recently.
If you are busy or no longer pursuing this, I would love to take it up and work on a fix. Let me know! Thanks.
I am on it, waiting for confirmation from maintainers
Ok
On Tue, 20 Jan, 2026, 20:10 Amrit Kumar Yadav, @.***> wrote:
DeveloperAmrit left a comment (AOSSIE-Org/PictoPy#1023) https://github.com/AOSSIE-Org/PictoPy/issues/1023#issuecomment-3773217485
I am on it, waiting for confirmation from maintainers
— Reply to this email directly, view it on GitHub https://github.com/AOSSIE-Org/PictoPy/issues/1023#issuecomment-3773217485, or unsubscribe https://github.com/notifications/unsubscribe-auth/BSRRFFY75CKEMUXYY6HLJSD4HY44VAVCNFSM6AAAAACRJNQ3S2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTONZTGIYTONBYGU . You are receiving this because you commented.Message ID: @.***>
@rohan-pandeyy This issue has been inactive for a while Did a full trace of all three symptoms - sharing root causes (file:line) in case it helps. Found a fourth, related issue too. Credit to @DeveloperAmrit for the original report + repro.
Bug 1 - clustering doesn't start automatically after AI tagging
post_AI_tagging_enabled_sequence() does call cluster_util_face_clusters_sync() (backend/app/routes/folders.py:94), but without force_full_reclustering, so it's gated by the 24h rule in cluster_util_is_reclustering_needed() (backend/app/utils/face_clusters.py:68). When that returns False it takes the incremental branch cluster_util_assign_cluster_to_faces_without_clusterId(), which bails at face_clusters.py:385 (if not cluster_means: return [], 0) when no clusters exist yet - so it can never create the first cluster. Made worse because enable_ai_tagging submits this to a ProcessPoolExecutor fire-and-forget (folders.py:244) and the function swallows exceptions (folders.py:95-97), so failures never reach the UI.
Bug 2 - groups don't disappear after removing a folder
Folder deletion correctly cascades (FK pragma on at folders.py:174; schema images.folder_id → folders ON DELETE CASCADE, faces.image_id → images ON DELETE CASCADE), so the faces are deleted. But the now-empty face_clusters row isn't, and the listing query db_get_all_clusters_with_face_counts (face_clusters.py:248) is a LEFT JOIN with no HAVING COUNT(f.face_id) > 0, so empty clusters still render.
Bug 3 - groups don't disappear even after Recluster (this is not a timeout)
cluster_util_face_clusters_sync(force_full=True) deletes clusters at face_clusters.py:138, but that line is unreachable when no faces remain because the function early-returns first at face_clusters.py:115 (if not results: return ...). So reclustering with 0 faces left leaves the old clusters in the DB forever.
Bug 4 - the delete-folder mutation only invalidates the ['folders'] query cache (frontend/src/hooks/useFolderOperations.tsx:130), never ['clusters'] (the recluster mutation does, ApplicationControlsCard.tsx:37). Remount-refetch masks it in this exact repro, but worth fixing defensively.
Fixes are small and independent: add the HAVING filter; move the cluster-delete above the early return; force a full cluster when none exist yet; add ['clusters'] to the delete invalidation.
@VanshajPoonia, please go ahead!
@VanshajPoonia if you are not working on this issue ,then can i work on it??
@Takitxt Yeah I am working on this issue