diff --git a/python/CustomVision/ImageClassification/CustomVisionQuickstart.py b/python/CustomVision/ImageClassification/CustomVisionQuickstart.py index 74931daf..3fea1b0c 100644 --- a/python/CustomVision/ImageClassification/CustomVisionQuickstart.py +++ b/python/CustomVision/ImageClassification/CustomVisionQuickstart.py @@ -39,7 +39,7 @@ # # -base_image_url = "/cognitive-services-python-sdk-samples/samples/vision/" +base_image_location = "/cognitive-services-python-sdk-samples/samples/vision/" print("Adding images...") @@ -47,12 +47,12 @@ for image_num in range(1, 11): file_name = "hemlock_{}.jpg".format(image_num) - with open(base_image_url + "images/Hemlock/" + file_name, "rb") as image_contents: + with open(base_image_location + "images/Hemlock/" + file_name, "rb") as image_contents: image_list.append(ImageFileCreateEntry(name=file_name, contents=image_contents.read(), tag_ids=[hemlock_tag.id])) for image_num in range(1, 11): file_name = "japanese_cherry_{}.jpg".format(image_num) - with open(base_image_url + "images/Japanese Cherry/" + file_name, "rb") as image_contents: + with open(base_image_location + "images/Japanese Cherry/" + file_name, "rb") as image_contents: image_list.append(ImageFileCreateEntry(name=file_name, contents=image_contents.read(), tag_ids=[cherry_tag.id])) upload_result = trainer.create_images_from_files(project.id, ImageFileCreateBatch(images=image_list)) @@ -88,7 +88,7 @@ prediction_credentials = ApiKeyCredentials(in_headers={"Prediction-key": prediction_key}) predictor = CustomVisionPredictionClient(ENDPOINT, prediction_credentials) -with open(base_image_url + "images/Test/test_image.jpg", "rb") as image_contents: +with open(base_image_location + "images/Test/test_image.jpg", "rb") as image_contents: results = predictor.classify_image( project.id, publish_iteration_name, image_contents.read()) diff --git a/python/CustomVision/ObjectDetection/CustomVisionQuickstart.py b/python/CustomVision/ObjectDetection/CustomVisionQuickstart.py index adab8feb..b71727df 100644 --- a/python/CustomVision/ObjectDetection/CustomVisionQuickstart.py +++ b/python/CustomVision/ObjectDetection/CustomVisionQuickstart.py @@ -88,7 +88,7 @@ # # Update this with the path to where you downloaded the images. -base_image_url = "/cognitive-services-python-sdk-samples/samples/vision/" +base_image_location = "/cognitive-services-python-sdk-samples/samples/vision/" # Go through the data table above and create the images print ("Adding images...") @@ -98,14 +98,14 @@ x,y,w,h = fork_image_regions[file_name] regions = [ Region(tag_id=fork_tag.id, left=x,top=y,width=w,height=h) ] - with open(base_image_url + "images/fork/" + file_name + ".jpg", mode="rb") as image_contents: + with open(base_image_location + "images/fork/" + file_name + ".jpg", mode="rb") as image_contents: tagged_images_with_regions.append(ImageFileCreateEntry(name=file_name, contents=image_contents.read(), regions=regions)) for file_name in scissors_image_regions.keys(): x,y,w,h = scissors_image_regions[file_name] regions = [ Region(tag_id=scissors_tag.id, left=x,top=y,width=w,height=h) ] - with open(base_image_url + "images/scissors/" + file_name + ".jpg", mode="rb") as image_contents: + with open(base_image_location + "images/scissors/" + file_name + ".jpg", mode="rb") as image_contents: tagged_images_with_regions.append(ImageFileCreateEntry(name=file_name, contents=image_contents.read(), regions=regions)) upload_result = trainer.create_images_from_files(project.id, ImageFileCreateBatch(images=tagged_images_with_regions)) @@ -135,7 +135,7 @@ # Now there is a trained endpoint that can be used to make a prediction # Open the sample image and get back the prediction results. -with open(base_image_url + "images/Test/test_od_image.jpg", mode="rb") as test_data: +with open(base_image_location + "images/Test/test_od_image.jpg", mode="rb") as test_data: results = predictor.detect_image(project.id, publish_iteration_name, test_data) # Display the results.