faces-cli 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FaceDiff extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ face: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
6
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ };
10
+ run(): Promise<unknown>;
11
+ }
@@ -0,0 +1,54 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ export default class FaceDiff extends BaseCommand {
5
+ static description = 'Compare owned faces pairwise across all centroid components';
6
+ static flags = {
7
+ ...BaseCommand.baseFlags,
8
+ face: Flags.string({
9
+ description: 'Face username to include (repeatable, min 2)',
10
+ multiple: true,
11
+ required: true,
12
+ }),
13
+ };
14
+ async run() {
15
+ const { flags } = await this.parse(FaceDiff);
16
+ const client = this.makeClient(flags);
17
+ if (flags.face.length < 2) {
18
+ this.error('At least 2 --face values are required');
19
+ }
20
+ const params = { faces: flags.face.join(',') };
21
+ let data;
22
+ try {
23
+ data = await client.get('/v1/faces/diff', { params });
24
+ }
25
+ catch (err) {
26
+ if (err instanceof FacesAPIError)
27
+ this.error(`Error (${err.statusCode}): ${err.message}`);
28
+ throw err;
29
+ }
30
+ if (!this.jsonEnabled()) {
31
+ const res = data;
32
+ const faces = res.faces;
33
+ const components = ['face', 'beta', 'delta', 'epsilon'];
34
+ for (let i = 0; i < faces.length; i++) {
35
+ for (let j = i + 1; j < faces.length; j++) {
36
+ const a = faces[i];
37
+ const b = faces[j];
38
+ const scores = res.similarity[a][b];
39
+ const parts = components.map(c => {
40
+ const v = scores[c];
41
+ return `${c}: ${v === null ? '—' : v.toFixed(2)}`;
42
+ });
43
+ this.log(`${a} ↔ ${b} ${parts.join(' ')}`);
44
+ }
45
+ }
46
+ this.log('');
47
+ const updated = Object.entries(res.centroids_updated_at)
48
+ .map(([face, ts]) => `${face} ${new Date(ts * 1000).toISOString().slice(0, 10)}`)
49
+ .join(', ');
50
+ this.log(`Centroids updated: ${updated}`);
51
+ }
52
+ return data;
53
+ }
54
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FaceNeighbors extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ k: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
6
+ component: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ direction: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ static args: {
13
+ face_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
14
+ };
15
+ run(): Promise<unknown>;
16
+ }
@@ -0,0 +1,62 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ export default class FaceNeighbors extends BaseCommand {
5
+ static description = 'Find the most similar or dissimilar owned faces to a given face';
6
+ static flags = {
7
+ ...BaseCommand.baseFlags,
8
+ k: Flags.integer({
9
+ description: 'Number of results (1–20)',
10
+ default: 5,
11
+ min: 1,
12
+ max: 20,
13
+ }),
14
+ component: Flags.string({
15
+ description: 'Centroid component to rank on (beta, delta, epsilon are the principal components of a face; face is their composite)',
16
+ options: ['face', 'beta', 'delta', 'epsilon'],
17
+ default: 'face',
18
+ }),
19
+ direction: Flags.string({
20
+ description: 'nearest (most similar) or furthest (most dissimilar)',
21
+ options: ['nearest', 'furthest'],
22
+ default: 'nearest',
23
+ }),
24
+ };
25
+ static args = {
26
+ face_id: Args.string({ description: 'Face username', required: true }),
27
+ };
28
+ async run() {
29
+ const { args, flags } = await this.parse(FaceNeighbors);
30
+ const client = this.makeClient(flags);
31
+ const params = {
32
+ k: String(flags.k),
33
+ component: flags.component,
34
+ direction: flags.direction,
35
+ };
36
+ let data;
37
+ try {
38
+ data = await client.get(`/v1/faces/${args.face_id}/neighbors`, { params });
39
+ }
40
+ catch (err) {
41
+ if (err instanceof FacesAPIError)
42
+ this.error(`Error (${err.statusCode}): ${err.message}`);
43
+ throw err;
44
+ }
45
+ if (!this.jsonEnabled()) {
46
+ const res = data;
47
+ const label = res.direction === 'nearest' ? 'Nearest' : 'Most dissimilar';
48
+ this.log(`${label} neighbors to ${res.face} (by ${res.component}):`);
49
+ this.log('');
50
+ if (res.neighbors.length === 0) {
51
+ this.log(' (none)');
52
+ }
53
+ else {
54
+ for (const [i, n] of res.neighbors.entries()) {
55
+ const updated = new Date(n.centroid_updated_at * 1000).toISOString().slice(0, 10);
56
+ this.log(` ${i + 1}. ${n.face.padEnd(20)} ${n.similarity.toFixed(2)} (centroid updated ${updated})`);
57
+ }
58
+ }
59
+ }
60
+ return data;
61
+ }
62
+ }