-
Notifications
You must be signed in to change notification settings - Fork 26
/
simple_face.ts
53 lines (48 loc) · 1.96 KB
/
simple_face.ts
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
import * as tf from '@tensorflow/tfjs'
import type { Model, Task, TaskProvider } from '../index.js'
import { models } from '../index.js'
import baseModel from '../models/mobileNetV2_35_alpha_2_classes.js'
export const simpleFace: TaskProvider<'image'> = {
getTask (): Task<'image'> {
return {
id: 'simple_face',
displayInformation: {
taskTitle: '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: '',
dataExampleText: 'Below you can find an example',
dataExampleImage: 'https://storage.googleapis.com/deai-313515.appspot.com/example_training_data/simple_face-example.png',
sampleDatasetLink: "https://storage.googleapis.com/deai-313515.appspot.com/example_training_data.tar.gz",
sampleDatasetInstructions: '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,
dataType: 'image',
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)
}
}