google-ai-edge / model-explorer

A modern model graph visualizer and debugger
Apache License 2.0
1.07k stars 87 forks source link

Allow to reuse server for pytorch models #245

Closed jinjingforever closed 2 weeks ago

jinjingforever commented 2 weeks ago

Also added tests to cover several pytorch related use cases.

The new API can be used as follows. I will update wiki after release next week:

# Assume the model explorer server has started at port 8080.

import model_explorer

# Prepare a pytorch model.
model = torchvision.models.mobilenet_v2().eval()
inputs = (torch.rand([1, 3, 224, 224]),)
ep = torch.export.export(model, inputs)

# Load it into the existing server.
model_explorer.visualize_pytorch('test pytorch', ep, reuse_server=True) # 👈

or:

import model_explorer

# Prepare a pytorch model.
model = torchvision.models.mobilenet_v2().eval()
inputs = (torch.rand([1, 3, 224, 224]),)
ep = torch.export.export(model, inputs)

# Load it into the existing server.
config.add_model_from_pytorch('torch test', ep).set_reuse_server() # 👈
model_explorer.visualize_from_config(config)

Fixes #231

yijie-yang commented 2 weeks ago

Thanks for adding more coverages in our CI!

jinjingforever commented 2 weeks ago

Thanks for adding more coverages in our CI!

Thanks for setting this up! Really nice to use and debug.