How to convert PyTorch model to Tensorflow

preview_player
Показать описание
In this video, we will convert the Pytorch model to Tensorflow using (Open Neural Network Exchange) ONNX. ONNX is a standard format supported by a community of partners such as Microsoft, Amazon, and IBM. PyTorch is mainly maintained by Facebook and Tensorflow is built in collaboration with Google.

Repository

Android application:

One year of unlimited online learning. Get 30% OFF Coursera Plus.

Expanda seus horizontes de carreira. Tenha 68% de desconto por um ano de Coursera Plus

Learn from experts at Google and get in-demand AI skills you can apply to your work right away with Google AI Essentials, with zero experience required.

Boost your software development career with Gen AI. Build in-demand, hands-on, Generative AI skills for elevating your software engineering game in 1 month or less.

Join the channel to get access to more perks:

Or visit my blog at:

Outro music: Sanaas Scylla

#pytorch #tensorflow #machinelearning
Рекомендации по теме
Комментарии
Автор

Hello Daniel, I am having this error
AttributeError: type object 'TFLiteConverterV2' has no attribute 'from_frozen_graph'

kidus
Автор

Would it be applicable for a model which is traned in Resnet50 (which uses Pytorch) to tensorflowlite

H-uu
Автор

Hello Daniel, Thanks for uploading this video on a guide to convert pytorch model to tflite, But actually i am stuck in a situation where i want to convert a Voice recognition model from Hugging face which is in availible in pytorch format and i want to convert it into tensorflow lite for my Mobile app, Can you please get the same concept and make a video of converting a voice recognition model from pytorch to tensorflow lite. I will be Very very thankfull for that pleasss

hammadmuhammad
Автор

Hello Daniel . I am using Checkpoints in my model but the given checkpoint is in .pth extension whereas model has .bin checkpoint file.. how can I use .pth as checkpoint in my model??

chandreshyadav
Автор

Hi.. Daniel.. I want to convert one pytorch model in tensorflow but i don't have the architecture of model.. I have just the model. I use the jit for load the model but I am not able to convert the model. Can you please help?

sonalibhargav
Автор

Hi Daniel, is there any way to convert a model from pytorch model to tensor flow check point (.ckpt, .meta, .index)

supremee
Автор

Hello Daniel. Thanks for great video.

Is there any way to not freeze the model when coverted to tensorflow? I need ckpt file but the module only produces pb file.

sondoongee
Автор

I keep getting this error when I try and convert my py torch file:

Traceback (most recent call last):
File "pytorch_to_tensorflow_lite.py", line 44, in <module>
trained_dict = torch.load(sys.argv[1], map_location={'cuda:0': 'cpu'})
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/serialization.py", line 584, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/serialization.py", line 842, in _load
result = unpickler.load()
ModuleNotFoundError: No module named 'models.yolo'

anandkrishnan
Автор

Hey @
Daniel Persson can you confirm that this method is still working in 2021 ?

shubhamthapa
Автор

hi Daniel i got the error
FileNotFoundError Traceback (most recent call last)
in <module>
1 # Load the trained model from file
----> 2 trained_dict = torch.load(sys.argv[1], map_location={'cuda:0': 'cpu'})
3
4 trained_model = MLP(784, [256, 256], 10)
5

in load(f, map_location, pickle_module, **pickle_load_args)
577 pickle_load_args['encoding'] = 'utf-8'
578
--> 579 with _open_file_like(f, 'rb') as opened_file:
580 if _is_zipfile(opened_file):
581 # The zipfile reader is going to advance the current file position.

in _open_file_like(name_or_buffer, mode)
228 def _open_file_like(name_or_buffer, mode):
229 if _is_path(name_or_buffer):
--> 230 return _open_file(name_or_buffer, mode)
231 else:
232 if 'w' in mode:

in __init__(self, name, mode)
209 class _open_file(_opener):
210 def __init__(self, name, mode):
--> 211 super(_open_file, self).__init__(open(name, mode))
212
213 def __exit__(self, *args):

FileNotFoundError: [Errno 2] No such file or directory: '-f'

amishajain
Автор

hey, daniel...is there a way to convert pytorch model to .h5 format

prabhatale