Azure Machine Learning studio - Images which have filename containing square brackets is not shown in outputs folder.

Akahoshi Masaya 46 Reputation points
2021-01-14T01:37:41.997+00:00

Hi, I am using Azure Machine Learning studio.

I trained my deep learning model on computing cluster, and then outputs images onto 'outputs' directory.
However, in Experiment > Run > outputs + logs tab, directories was displayed instead of my images.

Is it possible to get my images from 'outputs' directory?

After investigation, I recognized that images which have filename containing square brackets is not shown in the tab.
For instance, if I created 'outputs/test[0].jpg', then 'outputs/test' directory was shown in the tab.

[Sample code]

import cv2
import numpy as np
from pathlib import Path

# Check whether output directory exists or not
output_dir = Path('./outputs/')
if not output_dir.exists():
    output_dir.mkdir()

# Generate test image
IMAGE_SIZE = (28, 28)

test_image = np.zeros(IMAGE_SIZE)

# Save image with filename which contained / not contained square brackets
# 'test.jpg' and 'test' directory will be shown in the 'outputs' directory, however 'test[].jpg' and 'test[0].jpg' are disappeared.
cv2.imwrite(str(output_dir / 'test.jpg'), test_image)
cv2.imwrite(str(output_dir / 'test[].jpg'), test_image)
cv2.imwrite(str(output_dir / 'test[0].jpg'), test_image)
Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,337 questions
{count} votes

Accepted answer
  1. GiftA-MSFT 11,176 Reputation points
    2021-01-14T17:44:42.36+00:00

    Hi, it probably recognizes the square bracket as wildcard. Try using a double-backticks to escape the brackets, otherwise, I recommend you rename without the brackets and train again.

    cv2.imwrite(str(output_dir / 'test``[``].jpg'), test_image)
    
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Akahoshi Masaya 46 Reputation points
    2021-01-15T01:47:53.393+00:00

    Appreciate your reply.

    Although I tried adding double-backticks to escape square brackets, I cannot find my images in the workspace.

    [Fixed Code]

    (Omission)  
      
    # Save image with filename which contained / not contained square brackets  
    cv2.imwrite(str(output_dir / 'test.jpg'), test_image)  
    cv2.imwrite(str(output_dir / 'test[].jpg'), test_image)  
    cv2.imwrite(str(output_dir / 'test[0].jpg'), test_image)  
    cv2.imwrite(str(output_dir / 'test``[``].jpg'), test_image)  # Escape square brackets with double-backticks  
    cv2.imwrite(str(output_dir / 'test``[0``].jpg'), test_image) # Escape square brackets with double-backticks  
    

    Results:

    New directory with backticks appeared.

    56865-image.png

    And I will rename image files from next experiment,
    however I wish to get my image generated in my previous experiment because of the experiment's long elapsed time.
    Are there any good methods for that?


  2. Akahoshi Masaya 46 Reputation points
    2021-01-18T00:38:16.14+00:00

    Appreciate your help.

    I will re-execute my experiment with images renaming.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.