<jupyter_start><jupyter_text>Importing a model from ONNX We demonstrate how to import a model into Gamma from ONNX and draw the network.  Imports<jupyter_code>import os
import warnings; warnings.simplefilter(action='ignore', category=FutureWarning)

import onnx
from gamma import *
from gamma import convert<jupyter_output><empty_output><jupyter_text>1: Download the model<jupyter_code>fpath = utils.get_file('https://s3.amazonaws.com/download.onnx/models/squeezenet.tar.gz')
onnx_model = onnx.load(os.path.join(fpath, 'squeezenet/model.onnx'))<jupyter_output><empty_output><jupyter_text>2: Import into Gamma and draw<jupyter_code>graph = convert.from_onnx(onnx_model)
constants = {k for k, (v, i) in graph.items() if v['type'] == 'Constant'}
draw(strip(graph, constants))<jupyter_output><empty_output><jupyter_text>3: Export to ONNX and re-import<jupyter_code>onnx_model_2 = convert.to_onnx(graph, onnx_model.graph.name)
graph_2 = convert.from_onnx(onnx_model_2)
draw(strip(graph_2, constants))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11902439024390243, 'fraction_numerical': 0.007804878048780488, 'mean_word_length': 8.588785046728972, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '245614', 'license': 'MIT', 'n_tokens_mistral': 381, 'n_tokens_neox': 376, 'n_words': 72, 'path': 'examples/onnx_import.ipynb', 'repo_name': 'samgd/gamma', 'size': '1025'}