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

ValueError: Layer 'conv2d_9' expected 1 variables, but received 0 variables during loading. Expected: ['conv2d_9/kernel:0'] #1792

Open
MuhammadShifa opened this issue Nov 21, 2024 · 3 comments
Labels
framework: tensorflow Related to TensorFlow backend os: windows Involving Windows users type: bug Something isn't working

Comments

@MuhammadShifa
Copy link

MuhammadShifa commented Nov 21, 2024

Bug description

Hello thanks for the awesome package. I am going to process a pdf document with OCR but I am facing the issue in Window Machine. I have installed the doctr, tf and pt from source via the following line.

git clone https://github.com/mindee/doctr.git
pip install -e doctr/.
# for TensorFlow
pip install -e doctr/.[tf]
# for PyTorch
pip install -e doctr/.[torch]

Code snippet to reproduce the bug

from doctr.io import DocumentFile
from doctr.models import kie_predictor

# Model
model = kie_predictor(det_arch='db_resnet50', reco_arch='crnn_vgg16_bn', pretrained=True)
# PDF
doc = DocumentFile.from_pdf("./testing_doctr_ocr.pdf")
# Analyze
result = model(doc)

predictions = result.pages[0].predictions
for class_name in predictions.keys():
    list_predictions = predictions[class_name]
    for prediction in list_predictions:
        print(f"Prediction for {class_name}: {prediction}")```


### Error traceback

Traceback (most recent call last):
File "E:\OCR\ml_mo\doctr_mo\testing_doct.py", line 5, in
model = kie_predictor(det_arch='db_resnet50', reco_arch='crnn_vgg16_bn', pretrained=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\OCR\ml_mo\doctr\doctr\models\zoo.py", line 228, in kie_predictor
return _kie_predictor(
^^^^^^^^^^^^^^^
File "E:\OCR\ml_mo\doctr\doctr\models\zoo.py", line 146, in _kie_predictor
det_predictor = detection_predictor(
^^^^^^^^^^^^^^^^^^^^
File "E:\OCR\ml_mo\doctr\doctr\models\detection\zoo.py", line 110, in detection_predictor
return _predictor(
^^^^^^^^^^^
File "E:\OCR\ml_mo\doctr\doctr\models\detection\zoo.py", line 50, in _predictor
_model = detection.dict[arch](
^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\OCR\ml_mo\doctr\doctr\models\detection\differentiable_binarization\tensorflow.py", line 390, in db_resnet50
return _db_resnet(
^^^^^^^^^^^
File "E:\OCR\ml_mo\doctr\doctr\models\detection\differentiable_binarization\tensorflow.py", line 318, in _db_resnet
load_pretrained_params(
File "E:\OCR\ml_mo\doctr\doctr\models\utils\tensorflow.py", line 73, in load_pretrained_params
model.load_weights(archive_path, skip_mismatch=skip_mismatch)
File "C:\Users\admin\anaconda3\envs\doctr_ocr\Lib\site-packages\tf_keras\src\utils\traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\admin\anaconda3\envs\doctr_ocr\Lib\site-packages\tf_keras\src\engine\base_layer.py", line 3518, in load_own_variables
raise ValueError(
ValueError: Layer 'conv2d_9' expected 1 variables, but received 0 variables during loading. Expected: ['conv2d_9/kernel:0']


### Environment

WARNING:tensorflow:From C:\Users\admin\anaconda3\envs\doctr_ocr\Lib\site-packages\tf_keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.

WARNING:tensorflow:From C:\Users\admin\anaconda3\envs\doctr_ocr\Lib\site-packages\tf2onnx\tf_loader.py:68: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.

WARNING:tensorflow:From C:\Users\admin\anaconda3\envs\doctr_ocr\Lib\site-packages\tf2onnx\tf_loader.py:72: The name tf.train.import_meta_graph is deprecated. Please use tf.compat.v1.train.import_meta_graph instead.

WARNING:tensorflow:From C:\Users\admin\anaconda3\envs\doctr_ocr\Lib\site-packages\tf_keras\src\backend.py:873: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

Collecting environment information...

DocTR version: 0.10.1a0
TensorFlow version: 2.18.0
PyTorch version: 2.5.1+cpu (torchvision 0.20.1+cpu)
OpenCV version: 4.10.0
OS: Microsoft Windows 10 Pro
Python version: 3.11.10
Is CUDA available (TensorFlow): No
Is CUDA available (PyTorch): No
CUDA runtime version: 11.8.89
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
(doctr_ocr) PS E:\OCR\ml_mo\doctr\scripts>


### Deep Learning backend

is_tf_available: True
is_torch_available: True
@MuhammadShifa MuhammadShifa added the type: bug Something isn't working label Nov 21, 2024
@felixdittrich92 felixdittrich92 added os: windows Involving Windows users framework: tensorflow Related to TensorFlow backend labels Nov 21, 2024
@felixdittrich92
Copy link
Contributor

felixdittrich92 commented Nov 21, 2024

Hi @MuhammadShifa 👋,

Thanks for reporting this seems to be an issue with TensorFlow on Windows machines -> #1776

CC @odulcy-mindee Do we have a windows machine where we can try to reproduce the bug ? 😅

With linux everything works as expected -> CI also green

@MuhammadShifa
Copy link
Author

Hi @felixdittrich92 , @odulcy-mindee
Yes exactly, I am using the Window Machine.

@felixdittrich92
Copy link
Contributor

Quickly tested also with py3.11 in a docker container without issues.
So it's definitely related to Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework: tensorflow Related to TensorFlow backend os: windows Involving Windows users type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants