Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use original layer and blob names #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pytorch_to_caffe.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ def __init__(self):
self._blobs_data=[]
self.cnet=caffe_net.Caffemodel('')
self.debug=True
self.pytorch_layer_name=''

def init(self,inputs):
"""
:param inputs: is a list of input variables
"""
self.add_blobs(inputs)
def add_layer(self,name='layer'):
name+='_'
name+=self.pytorch_layer_name
if name in self.layers:
return self.layers[name]
if name not in self.detail_layers.keys():
Expand All @@ -67,7 +70,9 @@ def add_layer(self,name='layer'):
print("{} was added to layers".format(self.layers[name]))
return self.layers[name]

def add_blobs(self, blobs,name='blob',with_num=True):
def add_blobs(self, blobs,name='blob',with_num=False):
name+='_'
name+=self.pytorch_layer_name
rst=[]
for blob in blobs:
self._blobs_data.append(blob) # to block the memory address be rewrited
Expand Down