How to use the roots function from protobufjs

Find comprehensive JavaScript protobufjs.roots code examples handpicked from public code repositorys.

38
39
40
41
42
43
44
45
46
47
let meta_graph = null;
const identifier = context.identifier;
const extension = identifier.split('.').pop().toLowerCase();
if (extension === 'pbtxt' || identifier.toLowerCase().endsWith('.uff.txt')) {
    try {
        uff.proto = protobuf.roots.uff.uff;
        const reader = prototxt.TextReader.create(context.text);
        const field = reader.field;
        reader.field = (token, module) => {
            if (token === 'descriptors' || token === 'graphs' || token == 'referenced_data') {
fork icon0
star icon0
watch icon1

+ 3 other calls in file

21
22
23
24
25
26
27
28
29
30
    return;
}
var desc = null;
var identifier = context.identifier; 
try {
    paddle.proto = protobuf.roots.paddle.paddle.framework.proto;
    desc = paddle.proto.ProgramDesc.decode(context.buffer);
}
catch (error) {
    callback(new paddle.Error("File format is not paddle.ProgramDesc (" + error.message + ") in '" + identifier + "'."), null);
fork icon0
star icon0
watch icon1

64
65
66
67
68
69
70
71
72
73
host.require('./tf-proto', (err) => {
    if (err) {
        callback(err, null);
        return;
    }
    tf.proto = protobuf.roots.tf.tensorflow;
    var graph = null;
    var metaGraph = null;
    var savedModel = null;
    var format = null;
fork icon0
star icon0
watch icon3

33
34
35
36
37
38
39
40
41
42
host.require('./caffe-proto', (err) => {
    if (err) {
        callback(err, null);
        return;
    }
    caffe.proto = protobuf.roots.caffe.caffe;
    caffe.Metadata.open(host, (err, metadata) => {
        var extension = context.identifier.split('.').pop();
        if (extension == 'pbtxt' || extension == 'prototxt') {
            var tags = context.tags('pbtxt');
fork icon0
star icon0
watch icon1

66
67
68
69
70
71
72
73
74
75
if (extension == 'pbtxt' || extension == 'prototxt') {
    const open_text = (predict, init) => {
        let predict_net = null;
        let init_net = null;
        try {
            caffe2.proto = protobuf.roots.caffe2.caffe2;
            const reader = prototxt.TextReader.create(predict);
            reader.field = function(tag, message) {
                if (message instanceof caffe2.proto.DeviceOption) {
                    message[tag] = this.skip();
fork icon0
star icon0
watch icon0

+ 7 other calls in file

42
43
44
45
46
47
48
49
50
51
var model = null;
var identifier = context.identifier; 
var extension = identifier.split('.').pop().toLowerCase();
if (extension == 'pbtxt' || extension == 'prototxt') {
    try {
        onnx.proto = protobuf.roots.onnx.onnx;
        model = onnx.proto.ModelProto.decodeText(context.text);
    }
    catch (error) {
        host.exception(error, false);
fork icon0
star icon0
watch icon2

+ 3 other calls in file

16
17
18
19
20
21
22
23
24
25
open(context, host) { 
    return host.require('./coreml-proto').then(() => {
        var identifier = context.identifier;
        var decodedBuffer = null;
        try {
            coreml.proto = protobuf.roots.coreml.CoreML.Specification;
            decodedBuffer = coreml.proto.Model.decode(context.buffer);
        }
        catch (error) {
            throw new coreml.Error("File format is not coreml.Model (" + error.message + ") in '" + identifier + "'.");
fork icon0
star icon0
watch icon1

23
24
25
26
27
28
29
30
31
32
return host.require('./bigdl-proto').then(() => {
    return bigdl.Metadata.open(host).then((metadata) => {
        const identifier = context.identifier;
        try {
            // https://github.com/intel-analytics/BigDL/blob/master/spark/dl/src/main/resources/serialization/bigdl.proto
            bigdl.proto = protobuf.roots.bigdl.com.intel.analytics.bigdl.serialization;
            let module = bigdl.proto.BigDLModule.decode(context.buffer);
            return new bigdl.Model(metadata, module);
        }
        catch (error) {
fork icon0
star icon0
watch icon0