Repository: opencv
Issue: OpenCV with WebNN backend example fails to run
Labels: bug,category: dnn

##### System information (version)
- OpenCV => 4.5.5-dev
- Operating System / Platform => Ubuntu 21.10 (docker uses Ubuntu 18.04)
- Compiler => g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

##### Detailed description

I am creating this issue because I was trying to build this project following these instructions: https://github.com/opencv/opencv/pull/20406

And I have written a Dockerfile that starts from an out-of-the-box OpenVino image that automates this process to create an isolated container. It would be great to make it work in order to ease the building process.


```dockerfile
FROM openvino/ubuntu18_dev_no_samples AS deps

WORKDIR /app
USER root

# Install common known dependencies and download dnn weights for easy testing
RUN apt-get update \
    && apt-get install -y cmake default-jdk ffmpeg git gtk2.0 \ 
        libatlas-base-dev libavcodec-dev libavformat-dev libavresample-dev \
        libdc1394-22-dev libeigen3-dev libfaac-dev libgstreamer-plugins-base1.0-dev \
        libgstreamer1.0-dev libjpeg-dev libjpeg8-dev liblapacke-dev libmp3lame-dev \ 
        libopenblas-base libopenblas-dev libopencore-amrnb-dev libopencore-amrwb-dev \
        libpng-dev libprotobuf-dev libswscale-dev libtbb-dev libtbb2 libtheora-dev \
        libtiff-dev libtiff5-dev libv4l-dev libva-dev libvorbis-dev libxine2-dev \
        libxvidcore-dev make openjdk-8-jdk protobuf-compiler python python-dev \
        python-numpy qt5-default v4l-utils vim wget x264 x265 \
    && pip install flake8 \
    && git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git \
    && git clone https://github.com/opencv/opencv_extra \
    && cd opencv_extra/testdata/dnn/ \
    && python3 download_models.py GoogleNet \
    && mkdir /app/models \
    && mv bvlc_googlenet.caffemodel /app/models/googlenet-v1.caffemodel \
    && mv bvlc_googlenet.prototxt /app/models/googlenet-v1.prototxt



FROM deps

ENV PATH=/app/depot_tools:$PATH 
ENV WEBNN_NATIVE_DIR=/app/webnn-native/out/Release
ENV LD_LIBRARY_PATH=/app/opencv/build/lib:$WEBNN_NATIVE_DIR:$LD_LIBRARY_PATH 
ENV OPENCV_TEST_DATA_PATH=/app/opencv_extra/testdata/ 
ENV ngraph_DIR=/opt/intel/openvino/deployment_tools/ngraph/cmake/

# Build WebNN-native
RUN git clone https://github.com/opencv/opencv.git \
    && git clone https://github.com/webmachinelearning/webnn-native.git \
    && cd webnn-native \
    && git checkout c3cd14c \
    && cp scripts/standalone.gclient .gclient \
    && gclient sync \
    && gn gen out/Release "--args=is_debug=false webnn_enable_openvino=true" \
    && ninja -C out/Release \
    && cd ..

# Build OpenCV
RUN . /opt/intel/openvino_2021.4.752/bin/setupvars.sh \
    && cd /app/opencv \
    && mkdir build \
    && cd build \
    && cmake \
        -DCMAKE_BUILD_TYPE=Release \
        -DWITH_WEBNN=ON \
        -DBUILD_EXAMPLES=ON \
        -DBUILD_TEST=ON \
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        -DENABLE_CXX11=ON .. \
    && make -j6 
```



##### Steps to reproduce

Here are the commands to build and run the Docker image:
```shell
docker build -t cvwnn .
docker run --gpus all -it \
    --network=host \
    -e DISPLAY=$DISPLAY \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    --device /dev/dri:/dev/dri \
    --device-cgroup-rule='c 189:* rmw' \
    -v /dev/bus/usb:/dev/bus/usb cvwnn
```


But the problem I have is that I cannot get the /bin/example_dnn_classification example to succesfully run. Here is the error I am getting:


```shell
cd /app/opencv/build
./bin/example_dnn_classification \
    --model=/app/models/googlenet-v1.caffemodel \
    --config=/app/models/googlenet-v1.prototxt \
    --width=224 \
    --height=224 \
    --classes=/app/opencv/samples/data/dnn/classification_classes_ILSVRC2012.txt \
    --input=/app/opencv_extra/testdata/dnn/space_shuttle.jpg \
    --mean="104 117 123" \
    --rgb=false \
    --backend=6
mean: [104, 117, 123, 0]
std: [0, 0, 0, 0]
Gtk-Message: 11:56:53.397: Failed to load module "canberra-gtk-module"
[ WARN:0@0.154] global /app/opencv/modules/dnn/src/dnn.cpp (2202) initWebnnBackend Layer LRN name pool1/norm1 is unsupported by WebNN backend.
[ WARN:0@0.155] global /app/opencv/modules/dnn/src/dnn.cpp (2202) initWebnnBackend Layer LRN name conv2/norm2 is unsupported by WebNN backend.
[ WARN:0@0.156] global /app/opencv/modules/dnn/src/dnn.cpp (2202) initWebnnBackend Layer Dropout name pool5/drop_7x7_s1 is unsupported by WebNN backend.
The unexpected error message are : Check 'window_dilated_dim <= data_padded_dilated_dim' failed at core/src/validation_util.cpp:204:
While validating node 'v1::AvgPool AvgPool_1194 (Concat_1193[0]:f32{1,1024,6,6}) -> (dynamic?)' with friendly_name 'AvgPool_1194':
Window after dilation has dimension (dim: 7) larger than the data shape after padding (dim: 6) at axis 0.

Error: Failed to add the operand when building graph.
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.5.5-dev) /app/opencv/modules/dnn/src/op_webnn.cpp:93: error: (-215:Assertion failed) graph!=nullptr in function 'init'

Aborted (core dumped)
```

I would appreciate some help.