其實我的問題很簡單。我想在 tensorflow lite 模型中使用我自己的資料。所以,我寫了這行代碼:
root_path = r"C:\Users\90531\Desktop\dataset\b"
image_path = os.path.join(os.path.dirname(root_path), '1602854451425')
data = DataLoader.from_folder(image_path)
另外,這是我遇到的錯誤:
File "C:\Users\90531\AppData\Roaming\Python\Python39\site-packages\tensorflow_examples\lite\model_maker\core\data_util\image_dataloader.py", line 73, in from_folder
raise ValueError('Image size is zero')
ValueError: Image size is zero
uj5u.com熱心網友回復:
當Dataloader無法推斷影像的標簽時會發生這種情況。影像應根據它們所屬的類分為子檔案夾:
from tflite_model_maker.image_classifier import DataLoader
import seedir as sd
image_path = '/content/images'
sd.seedir(image_path, style='spaces', indent=4, anystart='- ')
data = DataLoader.from_folder(image_path)
- images/
- class1/
- result_image.png
- class2/
- result_image1.png
INFO:tensorflow:Load image with size: 2, num_label: 2, labels: class1, class2.

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/375441.html
