Face-Morphing / src /utils /sort_images.py
Robys01's picture
Added Align and Order Options
e425192
raw
history blame contribute delete
522 Bytes
from transformers import pipeline
def sort_images(image_files):
pipe = pipeline("image-classification", model="Robys01/facial_age_estimator")
def get_age(image):
result = pipe(image)
print(image, "age:", result[0]["label"])
return result[0]["label"]
image_files.sort(key=get_age)
return image_files
if __name__ == "__main__":
image_files = ["examples/3.png", "examples/1.png", "examples/2.png"]
sorted_images = sort_images(image_files)
print(sorted_images)