TFLite 模型官方代码分析

本文详细分析了TensorFlow Lite (TFLite) 模型的官方代码,探讨了如何将深度学习模型转换为TFLite格式,以便在移动端和嵌入式设备上实现高效运行。通过实例,解释了TFLite的优化过程,包括模型压缩和量化,以减少内存占用和提高执行速度。
摘要由CSDN通过智能技术生成
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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值