sample_id.ann.ann module

class sample_id.ann.ann.Matcher(metadata)[source]

Bases: abc.ABC

Nearest neighbor matcher that may use one of various implementations under the hood.

add_fingerprint(fingerprint, dedupe=True)[source]

Add a Fingerprint to the matcher.

Return type

Matcher

add_fingerprints(fingerprints, **kwargs)[source]

Add Fingerprints to the matcher.

Return type

Matcher

can_add_fingerprint(fingerprint)[source]

Check if fingerprint can be added to matcher.

Return type

bool

classmethod create(sr=None, hop_length=None, **kwargs)[source]

Create an instance, pass any kwargs needed by the subclass.

Return type

Matcher

filter_matches(matches, abs_thresh=0.25, ratio_thresh=None, cluster_dist=4.0, cluster_size=2, match_orientation=True, ordered=False, cluster_filter=None)[source]
Return type

List[Cluster]

find_samples(fp, k=1, abs_thresh=0.25, ratio_thresh=None, cluster_dist=20.0, cluster_size=2, match_orientation=True, ordered=False, cluster_filter=None)[source]
Return type

Result

classmethod from_fingerprint(fp, **kwargs)[source]

Useful for determining metadata for the Matcher based on the data being added.

Return type

Matcher

classmethod from_fingerprints(fingerprints, **kwargs)[source]

My data is small, just create and train the entire matcher.

Return type

Matcher

abstract init_model()[source]

Initialize the model.

Return type

Any

classmethod load(filepath, blocksize=10485760, threads=None, **kwargs)[source]

Load a matcher from disk.

Return type

Matcher

abstract load_model(filepath, **kwargs)[source]

Load this matcher’s model from disk.

Return type

Any

abstract nearest_neighbors(fp, k=1)[source]

Fetch nearest neighbors to this fingerprint’s keypoints.

Return type

Iterable[Match]

save(filepath, compress=True, compress_level=9, blocksize=10485760, threads=None, **kwargs)[source]

Save this matcher to disk.

Return type

str

abstract save_model(filepath, **kwargs)[source]

Save this matcher’s model to disk.

Return type

str

unload()[source]

Unload things from memory and cleanup any temporary files.

Return type

None

class sample_id.ann.ann.MatcherMetadata(sr=None, hop_length=None, index_to_id=None, index_to_kp=None, **kwargs)[source]

Bases: object

Metadata for a Matcher object.

classmethod load(filepath)[source]

Load this matcher’s metadata from disk.

Return type

MatcherMetadata

save(filepath, compress=True)[source]

Save this matcher’s metadata to disk.

Return type

None