forked from rai-project/dlframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_test.go
55 lines (50 loc) · 1.37 KB
/
model_test.go
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
package dlframework
import (
"testing"
"github.com/stretchr/testify/assert"
yaml "gopkg.in/yaml.v2"
)
const exampleModel = `name: Inception
framework:
name: TensorFlow
version: ~1.1.x
version: 3.0
description: >
An image-classification convolutional network.
Inception achieves 78.0% top-1 and 93.9% top-5 accuracy on the ILSVRC 2012 validation dataset.
It consists of fewer than 25M parameters.
references:
- https://arxiv.org/pdf/1512.00567.pdf
license: TODO
inputs:
- type: image
description: the input image
parameters:
dimensions: [1, 3, 224, 224]
mean: [117, 117, 117]
output:
type: feature
description: an output image net label
parameters:
features_url: http://data.dmlc.ml/mxnet/models/imagenet/synset.txt
model:
base_url: https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
graph_path: tensorflow_inception_graph.pb
is_archive: true
attributes:
manifest_author: abduld
trailing_dataset: ImageNet
`
func TestModelMarshaling(t *testing.T) {
var model ModelManifest
err := yaml.Unmarshal([]byte(exampleModel), &model)
assert.NoError(t, err)
bts, err := model.Marshal()
assert.NoError(t, err)
assert.NotEmpty(t, bts)
unmarshaledModel := ModelManifest{}
err = unmarshaledModel.Unmarshal(bts)
assert.NoError(t, err)
assert.NotEmpty(t, unmarshaledModel)
assert.True(t, model.Equal(unmarshaledModel))
}