-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathsimple_face.ts
More file actions
56 lines (51 loc) · 1.94 KB
/
simple_face.ts
File metadata and controls
56 lines (51 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import * as tf from '@tensorflow/tfjs'
import type { Model, TaskProvider } from "../index.js";
import { models } from '../index.js'
import baseModel from '../models/mobileNetV2_35_alpha_2_classes.js'
export const simpleFace: TaskProvider<"image", "federated"> = {
getTask() {
return Promise.resolve({
id: 'simple_face',
dataType: "image",
displayInformation: {
title: 'Simple Face',
summary: {
preview: 'Can you detect if the person in a picture is a child or an adult?',
overview: 'Simple face is a small subset of the public face_task dataset from Kaggle'
},
dataFormatInformation: '',
dataExample:
"https://storage.googleapis.com/deai-313515.appspot.com/example_training_data/simple_face-example.png",
sampleDataset: {
link: "https://storage.googleapis.com/deai-313515.appspot.com/example_training_data.tar.gz",
instructions:
'Opening the link should start downloading a zip file which you can unzip. Inside the "example_training_data" directory you should find the "simple_face" folder which contains the "adult" and "child" folders. To connect the data, select the Group option below and connect adults and children image groups.',
},
},
trainingInformation: {
epochs: 50,
roundDuration: 1,
validationSplit: 0.2,
batchSize: 10,
IMAGE_H: 200,
IMAGE_W: 200,
LABEL_LIST: ['child', 'adult'],
scheme: 'federated',
aggregationStrategy: 'mean',
minNbOfParticipants: 2,
tensorBackend: 'tfjs'
}
});
},
async getModel (): Promise<Model<'image'>> {
const model = await tf.loadLayersModel({
load: async () => Promise.resolve(baseModel),
});
model.compile({
optimizer: tf.train.sgd(0.001),
loss: 'categoricalCrossentropy',
metrics: ['accuracy']
})
return new models.TFJS('image', model)
}
}