• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Mac下安装python使用TensorFlow训练自己的模型

武飞扬头像
五个木
帮助1

程序猿日常

Mac下安装python使用TensorFlow训练自己的模型

目标

https://www.tensorflow.org/lite/models/modify/model_maker/image_classification?hl=zh-cn

安装Python3.8版本

下载地址双击安装

安装pip

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py

常用命令

卸载指定模块

pip3 uninstall ***模块名字

安装模块指定版本号

pip3 install --ignore-installed ***模块名字==版本号

安装模块 tflite-model-maker

pip3 install tflite-model-maker 

安装brew

/bin/zsh -c "$(curl -fsSL  https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

libusb-1.0.0.dylib (no such file) 安装libusb

brew install libusb

ImportError: cannot import name ‘array_record_module’ from ‘array_record.python’

git clone https://github.com/tensorflow/datasets /tmp/datasets
python3 -m pip install -e /tmp/datasets

运行 引用的模块正常

import os
import numpy as np

import tensorflow as tf
assert tf.__version__.startswith('2')

from tflite_model_maker import model_spec
from tflite_model_maker import image_classifier
from tflite_model_maker.config import ExportFormat
from tflite_model_maker.config import QuantizationConfig
from tflite_model_maker.image_classifier import DataLoader

import matplotlib.pyplot as plt

tf.keras.utils.get_file 加载网络数据集

image_path = tf.keras.utils.get_file(
  'flower_photos.tgz',
  'https://storage.谷歌apis.com/download.tensorflow.org/example_images/flower_photos.tgz',
  extract=True)
image_path = os.path.join(os.path.dirname(image_path), 'flower_photos')

tf.keras.utils.get_file 加载本地数据集

file:/// 三个/从本地获取

image_path = tf.keras.utils.get_file(
  'flower_photos.tgz',
  'file:///Users/lang/Desktop/python/flower_photos.zip',
  extract=True)
image_path = os.path.join(os.path.dirname(image_path), 'flower_photos')

数据集下载到默认缓存目录 ~/.keras

学新通
image_classifier.create 会报错 ssl证书验证失败

import ssl #全局取消证书验证
ssl._create_default_https_context = ssl._create_unverified_context #全局取消证书验证

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgjhcca
系列文章
更多 icon
同类精品
更多 icon
继续加载