This model performs color extraction from an image using KMeans clustering. Given an input image, the model identifies the dominant colors present in the image and returns their HEX codes, along with the color closest to white.
1from transformers import pipeline
2from PIL import Image
3
4# Load the color extraction pipeline
5color_extraction = pipeline("color-extraction")
6
7# Load an image using PIL (Python Imaging Library)
8image = Image.open("path/to/your/image.jpg")
9
10# Perform color extraction on the image
11colors, closest_to_white = color_extraction(image)
12
13# Print the results
14print("Dominant Colors:", colors)
15print("Color Closest to White:", closest_to_white)