-1

I'm trying to create deep learning model to detect "Face" in the images. I'm in the beginning phase and I'm facing an issue when I load my images.

I wish someone can support with solving this error

import os
import time
import uuid
import tensorflow as tf
import cv2
import json
import numpy as np
import matplotlib.pyplot as plt
IMAGES_PATH =  os.path.join('data','images')
number_images = 30
images_path ="File\\path\\data\\images"

## Review Dataset and build image loading function

import tensorflow as tf
import json
import numpy as np
from matplotlib import pyplot as plt

# Avoid OOM errors by setting GPU Memory Consumption Growth

gpus = tf.config.experimental.list_physical_devices('GPU')
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)

tf.config.list_physical_devices('GPU')

\#Load Image into TF Data Pipeline
\#images = tf.data.Dataset.list_files('data\\images\\\*.jpg')
images = tf.data.Dataset.list_files('C:\\file\\path\\data\\images')

images.as_numpy_iterator().next()

def load_image(x):
byte_img = tf.io.read_file(x)
img = tf.io.decode_jpeg(byte_img)
return img

images = images.map(load_image)

#When I run the below I get a access denied error

images.as_numpy_iterator().next()`\`

`UnknownError: {{function_node __wrapped__IteratorGetNext_output_types_1_device_/job:localhost/replica:0/task:0/device:CPU:0}} NewRandomAccessFile failed to Create/Open: C:\Users\M004955\Desktop\PythonProjects\testProjects\DetectionModel\data\images : Access is denied. ; Input/output error   [[{{node ReadFile}}]] [Op:IteratorGetNext] name:

I tried :

  1. Run as administrator
  2. File permission seems normal
wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • 2
    Welcome to Stack Overflow. Please read [ask] and make sure to **ask a question, after clearly explaining a specific problem**. "I'm facing an issue" tells us nothing. How exactly do you try running the code? **What happens** when you try running the code? **What should happen instead, and how is that different?** – Karl Knechtel Aug 29 '23 at 18:04
  • 1
    Please read the [formatting help](https://stackoverflow.com/help/formatting), and [edit] the post to make sure everything shows up properly - check the post preview before submitting. Make sure to show a [complete](https://meta.stackoverflow.com/questions/359146) error message, by **copying and pasting, starting from** the line that says `Traceback (most recent call last):` **until the end**, and formatting it as a **separate** multi-line code block. Make sure to avoid any extra junk in the code such as backslashes that aren't actually in the code - the new editor has some problems. – Karl Knechtel Aug 29 '23 at 18:05
  • Does this answer your question? [NewRandomAccessFile failed to Create/Open: output\_inference\_graph\_v1.pb : Access is denied](https://stackoverflow.com/questions/62946710/newrandomaccessfile-failed-to-create-open-output-inference-graph-v1-pb-access) – Matt Hall Aug 29 '23 at 18:20
  • Does the path exist? You will need to provide us with basic debugging info if you want there to be a chance that we can help you. Regardless, you should use `os.path.join()` to create file paths. This will help avoid any issues with slashes or backslashes. Also, make sure the folder structure and file paths are correct, and the images have the expected file extension. And I think most importantly, you need to step through the code line-by-line in a debugger and inspect the value of each variable at each step. – Random Davis Aug 29 '23 at 18:27
  • Try accessing that directory using other methods (`glob.glob`). – CristiFati Aug 29 '23 at 18:35

0 Answers0