diff --git a/app/main.py b/app/main.py index 7a37511..9d21c17 100644 --- a/app/main.py +++ b/app/main.py @@ -1211,14 +1211,28 @@ def add_tag(image_id): @main.post("/image//tags/remove") def remove_tag(image_id): + """Remove a tag from an image. + + Also logs a SuggestionFeedback rejection so the auto-suggest + auto-accept + systems treat this as 'the user said no to this tag for this image'. + Without the rejection row, a removed tag whose WD14 prediction still sits + at/above the auto-accept threshold would re-apply itself on the next + modal load. """ - Minimal JSON endpoint to remove a tag from an image. - """ + from app.models import SuggestionFeedback + name = (request.form.get("name") or "").strip() img = ImageRecord.query.get_or_404(image_id) tag = Tag.query.filter_by(name=name).first() if tag and tag in img.tags: img.tags.remove(tag) + db.session.add(SuggestionFeedback( + image_id=image_id, + tag_name=name, + suggestion_source='manual_removal', + confidence=0.0, + decision='rejected', + )) db.session.commit() return jsonify(ok=True)