这个函数需要最终返回一个基于狗狗图像文件名字的字典。 需要将宠物图像文件名读取后并提取当前宠物图像类别标签。
时间: 2024-05-25 18:18:39 浏览: 71
dog-breed-classifier:将狗的照片归类
def create_pet_dict(pet_image_files):
"""
Create a dictionary of pet images with their labels.
:param pet_image_files: List of filenames for pet images.
:return: Dictionary of pet images with their labels.
"""
pet_dict = {}
for file in pet_image_files:
# Extract the label from the filename
label = file.split("_")[0].lower()
if label not in pet_dict:
pet_dict[label] = [file]
else:
pet_dict[label].append(file)
return pet_dict
阅读全文