Home > Software engineering >  error: OpenCV(4.7.0) FAILED: fs.is_open(). Can't open "EDSR_x3.pb" in function '
error: OpenCV(4.7.0) FAILED: fs.is_open(). Can't open "EDSR_x3.pb" in function '

Time:01-06

Im trying out this article. But it doesn't work as intended.

This is the Python code copied from the article:

import cv2
from cv2 import dnn_superres

# Create an SR object
sr = dnn_superres.DnnSuperResImpl_create()

# Read image
image = cv2.imread('./raw_data/input.png')

# Read the desired model
path = "EDSR_x3.pb"
sr.readModel(path)

# Set the desired model and scale to get correct pre- and post-processing
sr.setModel("edsr", 3)

# Upscale the image
result = sr.upsample(image)

# Save the image
cv2.imwrite("./raw_data/upscaled.png", result)

But when I run it I get the error message:

error: OpenCV(4.7.0) /Users/runner/work/opencv-python/opencv-python/opencv/modules/dnn/src/caffe/caffe_io.cpp:1138: error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open "EDSR_x3.pb" in function 'ReadProtoFromBinaryFile'

I'm using OpenCV(4.7.0) (the contrib package), I downloaded the "EDSR_x3.pb" model which is on the same folder as the code, and I'm using the input image from the model's GitHub repo.

Does anyone know why it doesn't work or has the same issue?

CodePudding user response:

yes, my problem like as yours

Failed to parse GraphDef file: xxxxxx cv::dnn::ReadTFNetParamsFromBinaryFileOrDie'

although i insert this code for check that file,

print(os.path.isfile(path))

It''s tell True but nothing , then I change this file " EDSR_x4.pb " from other source too.

CodePudding user response:

I guess my error is

in function 'cv::dnn::ReadTFNetParamsFromBinaryFileOrDie'

i guess cv not CV2

CV is older version CV2 is newer version

but i try

import cv2.cv as cv

but it's still not work.

  • Related