Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

img_prep 'File {} was ignored' not actually ignoring files? #5

Open
GLawsonDuck opened this issue Apr 4, 2024 · 0 comments
Open

img_prep 'File {} was ignored' not actually ignoring files? #5

GLawsonDuck opened this issue Apr 4, 2024 · 0 comments

Comments

@GLawsonDuck
Copy link

GLawsonDuck commented Apr 4, 2024

I have repeatedly run across an issue of the preprocessing step failing partway through. As far as I can tell, this is due to a Windows-created desktop.ini file being flagged as 'ignored' but failing to actually be ignored:

File ./Photos\desktop.ini was ignored
File "C:\Users\\ML-Morph\ml-morph-v.1.0.0\preprocessing.py", line 17, in
file_sizes=utils.split_train_test(args['input_dir'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\
\ML-Morph\ml-morph-v.1.0.0\utils.py", line 245, in split_train_test
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^`
File "C:\Users\*\ML-Morph\ml-morph-v.1.0.0\utils.py", line 267, in image_prep
return file_sz
^^^^^^^

UnboundLocalError: cannot access local variable 'file_sz' where it is not associated with a value

The return statement fails due to 'file_sz' not existing.

The following slight modification appears to fix the issue and allow the extraneous file to actually get ignored:

(This is within utils.py)

def image_prep(file, name, dir_path):

Internal function used by the split_train_test function. Reads the original image files and, while 
converting them to jpg, gathers information on the original image dimensions. 

Parameters:
    file(str)=original path to the image file
    name(str)=basename of the original image file
    dir_path(str)= directory where the image file should be saved to
    
Returns:
    file_sz(array): original image dimensions

img = cv2.imread(file)
if img is None:
    print('File {} was ignored'.format(file))
    ****file_sz = [0, 0] #give the return statement something so it won't just fail? GLD****
else:
    file_sz= [img.shape[0],img.shape[1]]
    cv2.imwrite(os.path.join(dir_path,name), img)
return file_sz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant