BUG: Semantic search sees portrait phone photos sideways (SigLIP ignores EXIF orientation)

Aperta Adatta ai principianti
#1,780 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@jayssSmm ci sta già lavorando.

Dal 26/11/2026.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, pytorch

Direzione di ricerca

Inizia da backend/app/utils/SigLIP.py ed esamina siglip_util_preprocess_image(); l’issue indica il percorso di apertura e ridimensionamento delle immagini. Aggiungi un test unitario usando un JPEG con EXIF Orientation=6, come suggerito nell’issue. Il lavoro è completato quando l’output del preprocessing è diritto e il test verifica la gestione dell’orientamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug enhancement
Is there an existing issue for this?
  • I have searched the existing issues
What happened?

While going through the semantic search code I noticed that siglip_util_preprocess_image() in backend/app/utils/SigLIP.py doesn't handle EXIF orientation.

Phones usually store portrait photos as landscape pixels + an EXIF Orientation tag (like 6 = rotate 90° clockwise). Viewers read that tag and show the photo upright. But here the image is just opened and resized:

img = (
    Image.open(img_path)
    .convert("RGB")
    .resize((resolution, resolution), Image.BICUBIC)
)

so SigLIP ends up getting portrait phone photos turned sideways. That would hurt semantic search and semantic labels for basically any portrait photo taken on a phone.

The face/object side is fine btw, cv2.imread already applies EXIF orientation. So right now the same photo is upright for YOLO/FaceNet but sideways for SigLIP.

How I checked

I ran the actual siglip_util_preprocess_image() on a real phone photo with Orientation = 6 and turned the output tensor back into an image:

What you see What SigLIP gets
(drag 1_what_you_see.png here) (drag 2_what_siglip_sees.png here)

Also tried a small test image saved with Orientation=6 (red left half, blue right half). It displays with red on top, but SigLIP gets red on the left:

Displayed size (w,h):  (200, 400)
SigLIP input:   red in top half=0.50, red in left half=1.00
Upright photo:  red in top half=1.00, red in left half=0.50

Checked on dev at 3c6b10f.

Not a duplicate of

  • #1570 / #1596 - same cause, but only fixes thumbnails
  • #1727 - only the OpenCV loaders for faces/objects

Neither touches SigLIP.py.

Possible fix

Add ImageOps.exif_transpose() right after Image.open() and a unit test with an Orientation=6 JPEG. It's a small change.

One thing I wasn't sure about: photos that are already embedded will keep the old sideways embeddings. Should they get re-embedded as part of this, or is that better as a separate issue?

I'd like to work on this if that's okay.

1_what_you_see 2_what_siglip_sees
Record
  • I agree to follow this project's Code of Conduct
Lingua principale
Python
Stelle
322
Fork
793
Merge medio
6g 9h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AOSSIE-Org/PictoPy

Tutte le issue di AOSSIE-Org/PictoPy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.