--- title: Face Clustering keywords: fastai sidebar: home_sidebar nb_path: "nbs/indexers.FaceClusteringIndexer.indexer.ipynb" ---
test_registration(FaceClusteringIndexer)
You can test the model on your favorite images, we use 2 images from the modern family tv show as input and run the indexer. As per usual, you can run the indexer by calling indexer.index().
data_dir = PYI_TESTDATA / "photos" / "faceclustering"
photos = [IPhoto.from_path(path=x, size=640) for x in data_dir.ls() if str(x).endswith("jpg")]
data = IndexerData(photos=photos)
cluster_indexer = FaceClusteringIndexer()
items = cluster_indexer.index(data)
This generates a few data items for you, from various types. It creates photos and their files, which correspond to the crops of the faces and it creates Person items for the people in the crops.
set([type(i) for i in items])
The Person and Photo items are connected with an edge, called "occurence", you can inspect them as follows:
people = [x for x in items if isinstance(x, Person) and len(x.occurence) >=1]
print(len(people))
You can also test the full pipelines as if you are running it from the pod. You can do that as follows.
client = PodClient()
data_dir = PYI_TESTDATA / "photos" / "faceclustering"
photos = [IPhoto.from_path(path=x, size=640) for x in data_dir.ls() if str(x).endswith("jpg")]
indexer = Indexer.from_data(indexerClass="FaceClusteringIndexer", name="FaceClustering")
indexer_run = IndexerRun.from_data(progress=0, targetDataType="Photo")
for x in [indexer, indexer_run] + photos : client.create(x)
assert client.create_edge(Edge(indexer_run, indexer, "indexer"))
run_integrator(pod_full_address=DEFAULT_POD_ADDRESS,
integrator_run_uid=indexer_run.uid,
database_key=client.database_key,
owner_key=client.owner_key)
client.delete_all()