对于深度学习(基于计算机视觉),我已在 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)
我必须指定路径。我使用了很多不同的方法,直接传递服务提供给我的路径,但它们都不起作用:
- 直接从 Blob 存储中获取链接并传递它。
- 创建 Azure 数据存储并传递Folder_URI。
- 创建 Azure 数据 Assets 并传递
错误例如:
Could not find directory azureml://subscriptions/ data asset/images/Train
如何将正确的链接传递到文件夹以读取数据并开始在 Azure 机器学习笔记本中训练算法?
最佳答案
要从数据存储访问图像数据集,您可以在 azure ml 实例中装载数据存储。
数据已上传到数据存储中:
要挂载数据存储,您可以使用以下代码片段:
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()
This will mount the datastore at : "/tmp/image_dataset"
然后就可以使用该路径访问数据集了
也可以引用这个thread其中提供了在 Azure ML Notebook 中装载数据存储的更多详细信息。
关于python - 如何在 Azure ML Notebook 中使用 Blob 容器文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76785405/