odd_size flags every non-modal image size when IQR is 0

Abierto Apto para principiantes
#281 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
75/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
numpy, pandas, python

Línea de trabajo

Empieza leyendo SizeProperty.get_scores en issue_managers/image_property.py, centrándote en la rama threshold_gap == 0 y en cómo determina las marcas odd_size. Reproduce el comportamiento con las dos distribuciones de tamaños de imagen del issue y, después de un cambio, compara la cantidad de tamaños marcados; el resultado esperado indicado es que los tamaños minoritarios no se marquen todos como valores atípicos en ninguna de las dos distribuciones.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

When more than roughly 70-75 % of a dataset share one image size, q1 == q3 in
SizeProperty.get_scores (issue_managers/image_property.py). The threshold_gap == 0 branch
then sets self.threshold = 1.0, so every image whose size differs from that one value at all
is flagged as odd_size, even if it is only slightly larger or smaller.

This is common with photos downscaled to a fixed maximum side (phone photos all end up 384x512,
and anything with a different aspect ratio or a smaller original becomes "odd"). Whether a
dataset hits the branch depends on whether the modal share is above or below the quartile, so a
small change in composition switches between "nothing flagged" and "all minority sizes flagged".

Reproduction (cleanvision 0.3.7, Pillow 10.2.0, numpy 2.2.6, pandas 2.2.3):

import tempfile
from pathlib import Path

import numpy as np
from PIL import Image
from cleanvision import Imagelab

rng = np.random.default_rng(0)


def n_flagged(counts):
	with tempfile.TemporaryDirectory() as d:
		for (w, h), n in counts.items():
			for i in range(n):
				Image.fromarray(rng.integers(0, 255, (h, w, 3), dtype=np.uint8)).save(Path(d) / f"{w}x{h}_{i}.png")
		lab = Imagelab(data_path=d, verbose=False)
		lab.find_issues(issue_types={"odd_size": {}}, verbose=False)
		return int(lab.issues["is_odd_size_issue"].sum())


print(n_flagged({(384, 512): 140, (512, 512): 30, (512, 288): 30}))  # 60
print(n_flagged({(384, 512): 100, (512, 512): 60, (512, 288): 40}))  # 0

Expected: the same few (or no) images flagged in both cases (512x512 and 512x288 are not
outliers in either).

Possible fixes, any of these would do:

  • fall back to a relative tolerance around the median (e.g. flag only beyond a factor of x)
    instead of exact equality when IQR is 0
  • or skip the check with a warning when IQR is 0
Lenguaje dominante
Python
Estrellas
1.2k
Forks
87
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de cleanlab/cleanvision

Todos los issues de cleanlab/cleanvision

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.