geomat0101 / mediamgr

software for managing media libraries
0 stars 0 forks source link

image ingestion #19

Open geomat0101 opened 1 year ago

geomat0101 commented 1 year ago

assuming not a duplicate or banished content:

geomat0101 commented 1 year ago
    try:
        img = dlib.load_rgb_image(f)
        if max(img.shape) > 1024:
            resize = 1024./max(img.shape)
            img = dlib.resize_image(img, int(round(img.shape[0] * resize)), int(round(img.shape[1] * resize)))
    except RuntimeError as e:
        if str(e) == "Dlib only supports reading GIF files containing one image.":
            print(e)
            continue
        else:
            raise
    # The 1 in the second argument indicates that we should upsample the image
    # 2 times.  This will make everything bigger and allow us to detect more
    # faces.
    dets = cnn_face_detector(img, 2)

this scales down anything over 1024 pixels on its longest edge, then upscales it twice in cnn_face_detector. This seems to be memory-stable on the GPU at 3370MB per process