Coder Social home page Coder Social logo

Comments (7)

gafr avatar gafr commented on April 29, 2024 2

any update on this one?

from mmdnn.

Alan-Turing-Ko avatar Alan-Turing-Ko commented on April 29, 2024 2

Any update?

from mmdnn.

l8rpeace avatar l8rpeace commented on April 29, 2024 2

Any update on this?

from mmdnn.

ljie-PI avatar ljie-PI commented on April 29, 2024 1

any update on this :)

from mmdnn.

kitstar avatar kitstar commented on April 29, 2024

Slice layer of Caffe parser is not implemented. We will inform you asap. Thanks.

from mmdnn.

AllenMao avatar AllenMao commented on April 29, 2024

any update on this :)

from mmdnn.

BasicCoder avatar BasicCoder commented on April 29, 2024

I have an immature solution in caffe to tensorflow:
in mmdnn/conversion/caffe/shape.py add code:

def shape_slice(node):    
    print(node.parameters)    
    axis = node.parameters.axis    
    slices = len(node.parameters.slice_point) if len(node.parameters.slice_point) > 2 else 2    
    input_shape = node.get_only_parent()[0].output_shape    
    if axis == 1:    
        return TensorShape(input_shape.batch_size, input_shape.channels // slices, input_shape.height, input_shape.width)    
    elif axis == 2:    
        return TensorShape(input_shape.batch_size, input_shape.channels, input_shape.height // slices, input_shape.width)    
    elif axis == 3:    
        return TensorShape(input_shape.batch_size, input_shape.channels, input_shape.height, input_shape.width // slices)    
    return TensorShape(input_shape.batch_size, input_shape.channels // slices, input_shape.height, input_shape.width)    

in mmdnn/conversion/caffe/graph.py modify code:

...    
'Split': shape_split,    
'Slice': shape_slice,    
'TanH': shape_identity,    
...    

in mmdnn/conversion/caffe/mapper.py add code in class NodeMapper:

@classmethod    
 def map_slice(cls, node):    
       slices = len(node.parameters.slice_point) if len(node.parameters.slice_point) > 2 else 2    
       kwargs = {'axis': (2, 3, 1, 0)[node.parameters.axis], 'num_or_size_splits': slices}    
       cls._convert_output_shape(kwargs, node)    
       return Node.create('Split', **kwargs)    

so you can run command:

mmtoir -f caffe -n ./models/model.prototxt -w ./models/model.caffemodel -o caffe_model_IR    

mmtocode -f tensorflow --IRModelPath caffe_model_IR.pb --IRWeightPath caffe_model_IR.npy --dstModelPath tf_model_IR.py

It generates tensorflow model code: tf_model_IR.py
Now you can modify tf_model_IR.py source file to correspond to caffe model

Note:
This can only divide input tensor evenly.

from mmdnn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.