import os
def extract(path):
import tarfile
if path.endswith("tgz") or path.endswith("gz"):
#获取当前的绝对路径
dir_path = os.path.dirname(path)
tar = tarfile.open(path)
# 使用生成器函数而非列表来提取一个 tar 归档的子集:
tar.extractall(path=dir_path)
tar.close()
else:
raise RuntimeError("Could not decompress the file: " + path)
'''
from tvm.contrib.download import download_testdata
model_url = "http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224.tgz"
# Download model tar file and extract it to get mobilenet_v1_1.0_224.tflite
model_path = download_testdata(model_url, "mobilenet_v1_1.0_224.tgz", module=["tf", "official"])
'''
repo_base = '/home5/yunji.he/code/tvm/tests/mobilenet V1 TFLite/'
model_name = "mobilenet_v1_1.0_224.tgz"
model_path = os.path.join(repo_base, model_name)
TFLite 模型官方代码分析
最新推荐文章于 2024-08-13 18:03:26 发布
本文详细分析了TensorFlow Lite (TFLite) 模型的官方代码,探讨了如何将深度学习模型转换为TFLite格式,以便在移动端和嵌入式设备上实现高效运行。通过实例,解释了TFLite的优化过程,包括模型压缩和量化,以减少内存占用和提高执行速度。
摘要由CSDN通过智能技术生成