Open duguqiankun opened 5 years ago
@duguqiankun , thank you very much for the feedback. TensorFlow 2.0 is not officially released yet now. We will support it in future.
Hi! This library looks promising. As TF2.0 has been officially released for some time, do you have concrete plans regarding the support?
I successfully converted mxnet into TF2.0 model, the main idea is:
I have a blog which is in Chinese[中文],in this blog post, I convert mxnet model trained by InsightFace team, into TF2 model. Maybe it can help some guys. Here is the link: https://firstai.blog.csdn.net/article/details/108628300
Hi, I forked this repository and added the tf-keras
backend/framework. This is simply a port of keras
to tf.keras
and works with weights in HDF5 format. It seems to be working fine in TensorFlow 2.0, at least for my needs.
Example usage:
from tensorflow.keras import layers, Model
from tensorflow.keras.models import save_model
inp = layers.Input([10, 10, 3])
x = layers.Conv2D(5, 3)(inp)
x = layers.Flatten()(x)
x = layers.Dense(5)(x)
x = layers.Softmax()(x)
m = Model(inp, x)
save_model(m, 'model.h5', save_format='h5') # cannot be in frozen graph format
To convert:
mmconvert -sf tf-keras -iw model.h5 -df pytorch -om model.pt
This yields the files model.pt
and model.py
.
Loading:
import torch
import imp
MainModel = imp.load_source('MainModel', 'model.py')
model = torch.load('model.pt')
Eval:
>>> model.eval()
KitModel(
(conv2d): Conv2d(3, 5, kernel_size=(3, 3), stride=(1, 1))
(dense): Linear(in_features=320, out_features=5, bias=True)
)
My Versions:
>>> import tensorflow as tf; import torch
>>> tf.__version__
'2.1.3'
>>> torch.__version__
'1.3.1'
Platform (like ubuntu 16.04/win10):
Python version:
Source framework with version (like Tensorflow 1.4.1 with GPU):
Destination framework with version (like CNTK 2.3 with GPU):
Pre-trained model path (webpath or webdisk path):
Running scripts: