簡體   English   中英

如何將圖像數據集加載到 TensorFlow 中?

[英]How do I load image datasets into TensorFlow?

我是 TensorFlow 的新手,我正在嘗試在 Google Colaboratory 中構建一個小型神經網絡。 該網絡的目標是根據圖像識別個人的職業。 我有 900 張不同的圖像分別用於 10 個不同的工作作為我的訓練數據,以及來自每個工作的 200 個不同的圖像作為我的測試數據。 測試和訓練數據都下載到我的電腦上。 任何幫助將不勝感激。

首先將您的 Google Drive 安裝到 Collaboratory

from google.colab import drive
drive.mount('/content/drive')

訓練和測試數據所在目錄的路徑

train_dir  = '/content/drive/Training'
test_dir = '/content/drive/Testing'

創建用於訓練和測試的數據生成器

train_datagen = ImageDataGenerator(**datagen_kwargs)
test_datagen = ImageDataGenerator(**datagen_kwargs)

train_data = train_datagen.flow_from_directory(
    train_dir,
    target_size = (img_width, img_height),
    shuffle=True,
    batch_size = batch_size,
    classes = list(class_names))

test_data = test_datagen.flow_from_directory(
    test_dir,
    target_size = (img_width, img_height),
    shuffle=True,
    batch_size = batch_size,
    classes = list(class_names))

有關更多信息,請參閱此鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM