Spaces:
Running
Running
File size: 522 Bytes
e425192 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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)
|