Database schema:

CREATE TABLE "ATT_CLASSES" (
	"ATT_CLASS_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['0', '1'],
	"ATT_CLASS" TEXT NOT NULL -- example: ['indoors', 'building s'],
	PRIMARY KEY ("ATT_CLASS_ID")
)


CREATE TABLE "IMG_OBJ" (
	"IMG_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['2', '1'],
	"OBJ_SAMPLE_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['2', '1'],
	"OBJ_CLASS_ID" INTEGER -- example: ['246', '298'],
	"X" INTEGER -- example: ['0', '78'],
	"Y" INTEGER -- example: ['0', '308'],
	"W" INTEGER -- example: ['722', '799'],
	"H" INTEGER -- example: ['557', '290'],
	PRIMARY KEY ("IMG_ID", "OBJ_SAMPLE_ID"), 
	CONSTRAINT fk_img_obj_obj_classes FOREIGN KEY("OBJ_CLASS_ID") REFERENCES "OBJ_CLASSES" ("OBJ_CLASS_ID")
)


CREATE TABLE "IMG_OBJ_ATT" (
	"IMG_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['2', '1'],
	"ATT_CLASS_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['0', '1'],
	"OBJ_SAMPLE_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['22', '21'],
	PRIMARY KEY ("IMG_ID", "ATT_CLASS_ID", "OBJ_SAMPLE_ID"), 
	CONSTRAINT fk_img_obj_att_att_classes FOREIGN KEY("ATT_CLASS_ID") REFERENCES "ATT_CLASSES" ("ATT_CLASS_ID"),
	CONSTRAINT fk_img_obj_att_img_obj FOREIGN KEY("IMG_ID", "OBJ_SAMPLE_ID") REFERENCES "IMG_OBJ" ("IMG_ID", "OBJ_SAMPLE_ID")
)


CREATE TABLE "IMG_REL" (
	"IMG_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['2', '1'],
	"PRED_CLASS_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['0', '1'],
	"OBJ1_SAMPLE_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['13', '12'],
	"OBJ2_SAMPLE_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['1', '34'],
	PRIMARY KEY ("IMG_ID", "PRED_CLASS_ID", "OBJ1_SAMPLE_ID", "OBJ2_SAMPLE_ID"), 
	CONSTRAINT fk_img_rel_pred_classes FOREIGN KEY("PRED_CLASS_ID") REFERENCES "PRED_CLASSES" ("PRED_CLASS_ID"),
	CONSTRAINT fk_img_rel_img_obj FOREIGN KEY("IMG_ID", "OBJ1_SAMPLE_ID") REFERENCES "IMG_OBJ" ("IMG_ID", "OBJ_SAMPLE_ID"),
	CONSTRAINT fk_img_rel_img_obj FOREIGN KEY("IMG_ID", "OBJ2_SAMPLE_ID") REFERENCES "IMG_OBJ" ("IMG_ID", "OBJ_SAMPLE_ID")
)


CREATE TABLE "OBJ_CLASSES" (
	"OBJ_CLASS_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['0', '1'],
	"OBJ_CLASS" TEXT NOT NULL -- example: ['goggles', 'awning'],
	PRIMARY KEY ("OBJ_CLASS_ID")
)


CREATE TABLE "PRED_CLASSES" (
	"PRED_CLASS_ID" INTEGER DEFAULT 0 NOT NULL -- example: ['0', '1'],
	"PRED_CLASS" TEXT NOT NULL -- example: ['looking a', 'playing on'],
	PRIMARY KEY ("PRED_CLASS_ID")
)

Question: How many images have at least 5 "black" classes?
Evidence: images refers to IMG_ID; have at least 5 "black" classes refers to count(ATT_CLASS_ID) where ATT_CLASS = 'black' > = 5

SQL:
SELECT COUNT(IMGID) FROM ( SELECT T1.IMG_ID AS IMGID FROM IMG_OBJ_att AS T1 INNER JOIN ATT_CLASSES AS T2 ON T1.ATT_CLASS_ID = T2.ATT_CLASS_ID WHERE T2.ATT_CLASS = 'black' GROUP BY T1.IMG_ID HAVING COUNT(T1.ATT_CLASS_ID) >= 5 ) T3