netron-ui / netron.py
brianronan's picture
brianronan HF staff
Netron viewer embedded in a Space for easier model viewing.
8b4f646
raw
history blame contribute delete
963 Bytes
import os
netron_extensions = set([
".armnn",
".caffemodel",
".circle",
".ckpt",
".cmf",
".dlc",
".dnn",
".h5",
".har",
".hd5",
".hdf5",
".hn",
".keras",
".kmodel",
".lite",
".mar",
".meta",
".mge",
".mlmodel",
".mlnet",
".mlpackage",
".mnn",
".model",
".nb",
".ngf",
".nn",
".nnp",
".npy",
".npz",
".om",
".onnx",
".ort",
".paddle",
".param",
".pb",
".pbtxt",
".pdiparams",
".pdmodel",
".pdopt",
".pdparams",
".pkl",
".prototxt",
".pt",
".pth",
".ptl",
".rknn",
".safetensors",
".t7",
".tfl",
".tflite",
".tmfile",
".tm",
".tnnproto",
".torchscript",
".uff",
".xmodel",
])
def is_netron_file(file: str) -> bool:
_, ext = os.path.splitext(file)
if ext is None:
return False
return ext in netron_extensions
def build_netron_iframe(url: str) -> str:
return """
<iframe src="https://netron.app?url={url}" style="width:100%; height:70vh;"></iframe>
""".format(url=url)