python - 如何在 Azure ML Notebook 中使用 Blob 容器文件夹

标签 python azure azure-machine-learning-service

对于深度学习(基于计算机视觉),我已在 Azure Blob 容器中导入一个文件夹。该文件夹本身包含两个不同的文件夹“Train”和“Test”。在“Train”和“Test”文件夹中,根据我想要分类的 9 类图像,我有一组不同的文件夹。

现在,我想训练深度学习算法进行分类,以获得能够对这 9 个类别进行分类的模型,并且我想使用 Azure 机器学习笔记本 - 以及适当的计算实例。

现在,当我尝试使用代码调用 Blob 存储中的文件夹路径时:

 train_ds = tf.keras.preprocessing.image_dataset_from_directory(
   r'path', #here I have to specify the path 
   shuffle =True,
   image_size =(img_height,img_width)  , 
   batch_size = batch_size             # 32)

我必须指定路径。我使用了很多不同的方法,直接传递服务提供给我的路径,但它们都不起作用:

  1. 直接从 Blob 存储中获取链接并传递它。
  2. 创建 Azure 数据存储并传递Folder_URI。
  3. 创建 Azure 数据 Assets 并传递

错误例如:

 Could not find directory azureml://subscriptions/ data asset/images/Train

如何将正确的链接传递到文件夹以读取数据并开始在 Azure 机器学习笔记本中训练算法?

最佳答案

要从数据存储访问图像数据集,您可以在 azure ml 实例中装载数据存储。

数据已上传到数据存储中:

enter image description here

要挂载数据存储,您可以使用以下代码片段:

from azureml.core import Workspace, Datastore
from azureml.core.dataset import Dataset

ws = Workspace.from_config()
datastore = Datastore.get(ws, datastore_name='workspaceblobstore')
Image_dataset = Dataset.File.from_files((datastore, 'UI/2023-07-28_080518_UTC/image dataset/'))
mounted_path = "/tmp/image_dataset"
mount_cont = Image_dataset.mount(mounted_path)
mount_cont.start()

enter image description here

This will mount the datastore at : "/tmp/image_dataset"

然后就可以使用该路径访问数据集了 enter image description here

也可以引用这个thread其中提供了在 Azure ML Notebook 中装载数据存储的更多详细信息。

关于python - 如何在 Azure ML Notebook 中使用 Blob 容器文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76785405/

相关文章:

python - Azure MachineforMachine Learning 的测试数据中缺少数据

python - 通过 python 进行多人游戏

python - 与 Pandas 的音量叠加

asp.net - Azure 站点仅在使用远程数据库在本地运行时才有效

azure - 如何使用 az ml cli 获取在 Azure 机器学习服务模型注册表中注册的最新版本的模型 ID?

python - 如何删除 azureml 数据集(如果已存在)

Python Tkinter - 如何在按钮中显示 JPG 图像

python - 使用类作为其方法中参数的类型提示

azure - 如何通过 C# 创建 Azure API 管理实例?

c# - 基于 asp.net mvc 和 azure Active Directory 安全组的授权