Remove multiple Images from Person #1124

Closed
opened 2026-02-20 00:06:38 -05:00 by deekerman · 16 comments
Owner

Originally created by @monnypython on GitHub (Sep 29, 2021).

Hi,

i move all my images from Nextcloud to photoprism. I realy like it and it works very well :)

In my library with around 50,000 images, indexing and face recognition have been running for a few days. The results are really great.

When I renamed a picture from a person, a mistake like #1557 happened to me:

  • Person_A: 400 pictures
  • Person_B: 300 pictures
  • Change Name of a picture from Person_A to Person_B (without "reject"!) --> my bad :(
  • Result: Person_B 700 pictures

I don't see any way to correct the mistake without removing every single picture of the person, right?
I have the following workflows in mind:

  • Remove a whole person in the overview to release the images for a reindex
  • Select several pictures of a person and execute a "Reject all" function
  • Select several pictures of a person und change the name
Originally created by @monnypython on GitHub (Sep 29, 2021). Hi, i move all my images from Nextcloud to photoprism. I realy like it and it works very well :) In my library with around 50,000 images, indexing and face recognition have been running for a few days. The results are really great. When I renamed a picture from a person, a mistake like #1557 happened to me: - Person_A: 400 pictures - Person_B: 300 pictures - Change Name of a picture from Person_A to Person_B (without "reject"!) --> my bad :( - Result: Person_B 700 pictures I don't see any way to correct the mistake without removing every single picture of the person, right? I have the following workflows in mind: - Remove a whole person in the overview to release the images for a reindex - Select several pictures of a person and execute a "Reject all" function - Select several pictures of a person und change the name
deekerman 2026-02-20 00:06:38 -05:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@graciousgrey commented on GitHub (Sep 29, 2021):

We are going to change the renaming behavior, so that this "mistake" cannot happen again.

Batch reject is not possible yet. Might be part of (#271).

You can use the faces reset command to reset all faces. This will delete everything face/people related, so that you can start from scratch.
After that you can use faces index to index faces again. This is faster than a complete rescan.

@graciousgrey commented on GitHub (Sep 29, 2021): We are going to change the renaming behavior, so that this "mistake" cannot happen again. Batch reject is not possible yet. Might be part of (#271). You can use the faces reset command to reset all faces. This will delete everything face/people related, so that you can start from scratch. After that you can use faces index to index faces again. This is faster than a complete rescan.
Author
Owner

@monnypython commented on GitHub (Sep 30, 2021):

OK. Thanks for the hints.

@monnypython commented on GitHub (Sep 30, 2021): OK. Thanks for the hints.
Author
Owner

@maximecurioni commented on GitHub (Oct 2, 2021):

@monnypython I ran into the same issue today and wrote an API script to remove a person.

The script is ugly and verbose, but it seems to work on my three removals.

If you are confident running a Python3 script and don't mind removing a person altogether, here it is below. You need to:

  • in your Python script:
    • update the API_ROOT constant with your URL (it must end in v1/api)
    • update the NAME constant with the exact name of the person you want to remove
    • you may need to update the different counts used or run your script multiple times
    • make sure that the requests Python library is installed on your machine
  • in your shell:
    • before running the script, you need to export the PHOTOPRISM_SESSION_ID environment variable with the value from your browser (type localStorage.session_id in your DevTools console): export PHOTOPRISM_SESSION_ID=...
import json
import os
import sys

import requests

API_ROOT = 'http://localhost:2342/api/v1'
NAME = "John Doe"
session_id = None

def get(url):
    headers = {'X-Session-ID': session_id}
    request_url = API_ROOT + url
    print("\n", "--> GET", request_url)

    r = requests.get(request_url, headers=headers)
    if r.status_code != 200:
        print("Error", r.content)
    try:
        j = json.loads(r.content)
        return j
    except:
        print("Invalid JSON")
        return [None]


def delete(url):
    headers = {'X-Session-ID': session_id}
    request_url = API_ROOT + url
    print("\n", "--> DELETE", request_url)

    r = requests.delete(request_url, headers=headers)
    if r.status_code == 200:
        print("==> Success")
    else:
        print("Error", r.content)


# Make sure we have a session ID
session_id = os.getenv('PHOTOPRISM_SESSION_ID')
if not session_id:
    sys.exit('Missing PHOTOPRISM_SESSION_ID environment variable')

people = get('/subjects?count=200')
print("People found", len(people))

person = [person for person in people if person['Name'] == NAME]
if len(person) > 0:
    person = person[0]
else:
    sys.exit('Cannot find', NAME)

person_id = person['UID']
print("\nFound", NAME)
print(json.dumps(person))

photos = get('/photos?count=500&q=person%3A' + NAME)
print("Photos found", len(photos))

for photo in photos:
    print("\n################")
    photo_id = photo['UID']
    photo_metadata = get('/photos/' + photo_id)

    markers = []
    try:
        markers = photo_metadata['Files'][0]['Markers']
    except:
        pass

    print("Total markers count", len(markers))

    person_face_markers = [
        marker for marker in markers if marker['Type'] == 'face' and marker['SubjUID'] == person_id]
    print("Matching person face markers", len(person_face_markers))

    if len(person_face_markers) > 0:
        print("Removing", NAME, "from", photo_id)
        marker = person_face_markers[0]
        delete('/markers/' + marker['UID'] + '/subject')
@maximecurioni commented on GitHub (Oct 2, 2021): @monnypython I ran into the same issue today and wrote an API script to remove a person. The script is ugly and verbose, but it seems to work on my three removals. If you are confident running a Python3 script and don't mind removing a person altogether, here it is below. You need to: - in your Python script: - update the `API_ROOT` constant with your URL (it must end in `v1/api`) - update the `NAME` constant with the exact name of the person you want to remove - you may need to update the different counts used or run your script multiple times - make sure that the `requests` Python library is installed on your machine - in your shell: - before running the script, you need to export the `PHOTOPRISM_SESSION_ID` environment variable with the value from your browser (type `localStorage.session_id` in your DevTools console): `export PHOTOPRISM_SESSION_ID=...` ``` import json import os import sys import requests API_ROOT = 'http://localhost:2342/api/v1' NAME = "John Doe" session_id = None def get(url): headers = {'X-Session-ID': session_id} request_url = API_ROOT + url print("\n", "--> GET", request_url) r = requests.get(request_url, headers=headers) if r.status_code != 200: print("Error", r.content) try: j = json.loads(r.content) return j except: print("Invalid JSON") return [None] def delete(url): headers = {'X-Session-ID': session_id} request_url = API_ROOT + url print("\n", "--> DELETE", request_url) r = requests.delete(request_url, headers=headers) if r.status_code == 200: print("==> Success") else: print("Error", r.content) # Make sure we have a session ID session_id = os.getenv('PHOTOPRISM_SESSION_ID') if not session_id: sys.exit('Missing PHOTOPRISM_SESSION_ID environment variable') people = get('/subjects?count=200') print("People found", len(people)) person = [person for person in people if person['Name'] == NAME] if len(person) > 0: person = person[0] else: sys.exit('Cannot find', NAME) person_id = person['UID'] print("\nFound", NAME) print(json.dumps(person)) photos = get('/photos?count=500&q=person%3A' + NAME) print("Photos found", len(photos)) for photo in photos: print("\n################") photo_id = photo['UID'] photo_metadata = get('/photos/' + photo_id) markers = [] try: markers = photo_metadata['Files'][0]['Markers'] except: pass print("Total markers count", len(markers)) person_face_markers = [ marker for marker in markers if marker['Type'] == 'face' and marker['SubjUID'] == person_id] print("Matching person face markers", len(person_face_markers)) if len(person_face_markers) > 0: print("Removing", NAME, "from", photo_id) marker = person_face_markers[0] delete('/markers/' + marker['UID'] + '/subject') ```
Author
Owner

@lastzero commented on GitHub (Oct 3, 2021):

Note you can easily reset and re-index faces if needed (for example after upgrading or when you made a big mistake that takes long to fix otherwise):

docker-compose exec photoprism photoprism faces reset -f
docker-compose exec photoprism photoprism faces index

Naming usually just takes a few minutes. With our new version released yesterday, you may even get better detection results with fewer false positives.

@lastzero commented on GitHub (Oct 3, 2021): Note you can easily reset and re-index faces if needed (for example after upgrading or when you made a big mistake that takes long to fix otherwise): ``` docker-compose exec photoprism photoprism faces reset -f docker-compose exec photoprism photoprism faces index ``` Naming usually just takes a few minutes. With our new version released yesterday, you may even get better detection results with fewer false positives.
Author
Owner

@dror3go commented on GitHub (Oct 3, 2021):

@lastzero A reset will remove anything faces/people related?
I'm not sure how to continue after an accidental reject which seems to rejected ~200 tagged images, and also if I want to upgrade to the latest release.
Is it the recommended way to reset the faces after the latest upgrade?
I personally manually tagged people for several hours, so I prefer not to do that again if possible.

@dror3go commented on GitHub (Oct 3, 2021): @lastzero A reset will remove anything faces/people related? I'm not sure how to continue after an accidental reject which seems to rejected ~200 tagged images, and also if I want to upgrade to the latest release. Is it the recommended way to reset the faces after the latest upgrade? I personally manually tagged people for several hours, so I prefer not to do that again if possible.
Author
Owner

@lastzero commented on GitHub (Oct 3, 2021):

Yes, it will remove all face clusters, face markers, and people. Nothing else.

@lastzero commented on GitHub (Oct 3, 2021): Yes, it will remove all face clusters, face markers, and people. Nothing else.
Author
Owner

@lastzero commented on GitHub (Oct 3, 2021):

To keep existing people and face markers, and can just remove what has been created automatically (won't touch already named people though and I thought that is your primary issue):

docker-compose exec photoprism photoprism faces reset
@lastzero commented on GitHub (Oct 3, 2021): To keep existing people and face markers, and can just remove what has been created automatically (won't touch already named people though and I thought that is your primary issue): ``` docker-compose exec photoprism photoprism faces reset ```
Author
Owner

@dror3go commented on GitHub (Oct 3, 2021):

I'm not the original author of this ticket :)
I guess my question is generic - whether or not we should reset the faces after upgrading to the latest release.

@dror3go commented on GitHub (Oct 3, 2021): I'm not the original author of this ticket :) I guess my question is generic - whether or not we should reset the faces after upgrading to the latest release.
Author
Owner

@lastzero commented on GitHub (Oct 3, 2021):

If you're happy with the results and didn't make a mistake you want to fix anyway, you don't have to. The new release is better at ignoring false positives, which leads to less noise and better performance (as less faces need to compared with each other). Also it enables you to detect smaller faces if you want to (see PHOTOPRISM_FACE_SIZE in our docs)

@lastzero commented on GitHub (Oct 3, 2021): If you're happy with the results and didn't make a mistake you want to fix anyway, you don't have to. The new release is better at ignoring false positives, which leads to less noise and better performance (as less faces need to compared with each other). Also it enables you to detect smaller faces if you want to (see `PHOTOPRISM_FACE_SIZE` in our [docs](https://docs.photoprism.org/getting-started/config-options/))
Author
Owner

@layanto commented on GitHub (Oct 12, 2021):

I too made mistakes in accidentally combining two people. How do I reset the Title and Description fields as now they have incorrect person(s)? Searching includes these fields resulting in incorrect photos returned.

@layanto commented on GitHub (Oct 12, 2021): I too made mistakes in accidentally combining two people. How do I reset the Title and Description fields as now they have incorrect person(s)? Searching includes these fields resulting in incorrect photos returned.
Author
Owner

@lastzero commented on GitHub (Oct 12, 2021):

You can unassign names in the photo edit dialog people tab. Titles and descriptions get updated asynchronously in the background.

@lastzero commented on GitHub (Oct 12, 2021): You can unassign names in the photo edit dialog people tab. Titles and descriptions get updated asynchronously in the background.
Author
Owner

@dessalines commented on GitHub (Apr 25, 2023):

I accidentally tagged two faces as the same name, and it combined hundreds of pictures of two people into the same name. It seems like the only way to correct this is to do a full face rescan?

@dessalines commented on GitHub (Apr 25, 2023): I accidentally tagged two faces as the same name, and it combined hundreds of pictures of two people into the same name. It seems like the only way to correct this is to do a full face rescan?
Author
Owner

@lastzero commented on GitHub (Apr 25, 2023):

Conflict resolution will split the clusters again when you press the eject button next to a name and enter the right name.

@lastzero commented on GitHub (Apr 25, 2023): Conflict resolution will split the clusters again when you press the eject button next to a name and enter the right name.
Author
Owner

@maurizioandreotti commented on GitHub (Oct 5, 2023):

In my case adding removing persons is just terribly slow. even to the "eject" a person takes around a minute.

@maurizioandreotti commented on GitHub (Oct 5, 2023): In my case adding removing persons is just terribly slow. even to the "eject" a person takes around a minute.
Author
Owner

@lastzero commented on GitHub (Oct 5, 2023):

@maurizioandreotti This could be a software problem, but it could also be slow hardware or a bad database setup. Without knowing additional details, we can't help.

@lastzero commented on GitHub (Oct 5, 2023): @maurizioandreotti This could be a software problem, but it could also be slow hardware or a bad database setup. Without knowing additional details, we can't help.
Author
Owner

@maurizioandreotti commented on GitHub (Oct 5, 2023):

Photoprism is managing >40k photos (mainly JPG and CR2/CR3)

I installed it last Saturday as an Open MediaVault plugin with hardware:

Versione 6.9.2-1 (Shaitan)
Processor AMD Athlon(tm) II X2 215 Processor
Kernel Linux 6.1.0-0.deb11.11-amd64
Load Average 3.43, 3.02, 2.71
Memory Usage 49.1% of 5.54 GiB

120GB SDD as system disk (fully dedicated to openmediavault)
2x4TB HDD as data disk (no raid - one shared via samba on the local LAN,
the other synched with night batch)
2x300GB HDD as data disk (no raid - one shared via samba on the local LAN,
the other synched with night batch)

the photoprism DB in located on a different share of the 4TB disk (same
place of the photos)

If it could improve, I could move the DB on the 300GB disk which is also
shared but mostly unused and free... is there a way to do that without
loosing the indexing it has already done?

Il giorno gio 5 ott 2023 alle ore 16:25 Michael Mayer <
@.***> ha scritto:

@maurizioandreotti https://github.com/maurizioandreotti This could be a
software problem, but it could also be slow hardware or a bad database
setup. Without knowing additional details, we can't help.


Reply to this email directly, view it on GitHub
https://github.com/photoprism/photoprism/issues/1569#issuecomment-1749017913,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AB2W7OWZ6SA6C4MKBY4NCUTX527OJAVCNFSM5E72S7I2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZUHEYDCNZZGEZQ
.
You are receiving this because you were mentioned.Message ID:
@.***>

@maurizioandreotti commented on GitHub (Oct 5, 2023): Photoprism is managing >40k photos (mainly JPG and CR2/CR3) I installed it last Saturday as an Open MediaVault plugin with hardware: Versione 6.9.2-1 (Shaitan) Processor AMD Athlon(tm) II X2 215 Processor Kernel Linux 6.1.0-0.deb11.11-amd64 Load Average 3.43, 3.02, 2.71 Memory Usage 49.1% of 5.54 GiB 120GB SDD as system disk (fully dedicated to openmediavault) 2x4TB HDD as data disk (no raid - one shared via samba on the local LAN, the other synched with night batch) 2x300GB HDD as data disk (no raid - one shared via samba on the local LAN, the other synched with night batch) the photoprism DB in located on a different share of the 4TB disk (same place of the photos) If it could improve, I could move the DB on the 300GB disk which is also shared but mostly unused and free... is there a way to do that without loosing the indexing it has already done? Il giorno gio 5 ott 2023 alle ore 16:25 Michael Mayer < ***@***.***> ha scritto: > @maurizioandreotti <https://github.com/maurizioandreotti> This could be a > software problem, but it could also be slow hardware or a bad database > setup. Without knowing additional details, we can't help. > > — > Reply to this email directly, view it on GitHub > <https://github.com/photoprism/photoprism/issues/1569#issuecomment-1749017913>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AB2W7OWZ6SA6C4MKBY4NCUTX527OJAVCNFSM5E72S7I2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZUHEYDCNZZGEZQ> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/photoprism#1124
No description provided.