Skip to content

Cannot upload images to a customvision project #12262

Closed

Description

  • Package Name: azure-cognitiveservices-vision-customvision
  • Package Version: 3.0.0
  • Operating System: Ubuntu 18.04
  • Python Version: 3.6.9

Describe the bug
I tried to follow https://docs.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/quickstarts/object-detection?pivots=programming-language-python to upload my image to the project.

I got this error

msrest.exceptions.SerializationError: Unable to build a model: Unable to deserialize to object: type, AttributeError: 'ImageFileCreateEntry' object has no attribute 'lower', DeserializationError: Unable to deserialize to object: type, AttributeError: 'ImageFileCreateEntry' object has no attribute 'lower'

code snippet

credentials = ApiKeyCredentials(in_headers={"Training-key": training_key})
trainer = CustomVisionTrainingClient(endpoint=ENDPOINT, credentials=credentials)
for fol in tqdm(os.listdir(base_path)):
    savepath = os.path.join(base_path,fol)
    allfiles =  os.listdir(savepath)
    image_list = list()
    for fname in random.sample(allfiles,5):
        with open(os.path.join(savepath,fname), "rb") as image_contents:
            image_list.append(ImageFileCreateEntry(name=fname, contents=image_contents.read()))
    upload_result = trainer.create_images_from_files(project_id, image_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Cognitive - Custom VisionService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions