TNTWEN / OpenVINO-YOLOV4

This is implementation of YOLOv4,YOLOv4-relu,YOLOv4-tiny,YOLOv4-tiny-3l,Scaled-YOLOv4 and INT8 Quantization in OpenVINO2021.3
MIT License
238 stars 66 forks source link

hello #68

Open chang556 opened 2 years ago

chang556 commented 2 years ago

AttributeError: module ‘tensorflow‘ has no attribute ‘contrib‘

how can use ,because we are usu openvino2021.4.2

microboym commented 2 years ago

I recently succeeded in converting my model with openvino2021.4.

  1. I created a separated virtual environment with anaconda, and run the following commands:

    condo activate openvino-yolov4
    conda install python==3.6.4
    conda install pip
    pip install tensorflow==1.15.5
    pip install tqdm sklearn
    python convert_weights_pb.py --class_names cfg/<your model>.names --weights_file <your model>.weights --data_format NHWC

    which generated the frozen_darknet_yolov4_model.pb file.

  2. I used my os python /usr/bin/python3 to create a venv, which was different from the condo env I had created, because OpenVINO seemed not capable with anaconda.

    bash # use a different shell that has not been init with conda. I used zsh before so now I used bash.
    /usr/bin/python3 -m pip install virtualenv
    /usr/bin/python3 -m virtualenv -p `which python3` <directory_for_environment>
    source <directory_for_environment>/bin/activate
# Than follow the installation guide provided by intel.
source /opt/intel/openvino_2021/bin/setupvars.sh
cd /opt/intel/openvino_2021/deployment_tools/model_optimizer/install_prerequisites
sudo ./install_prerequisites_tf.sh ## DO NOT use ./install_prerequisites.sh or ./install_prerequisites_tf2.sh
  1. Finally, modify yolov4.json and run the mo script in the env created in step 2.
    ### Remember to use the same shell that you performed step2
    python3 "/opt/intel/openvino_2021/deployment_tools/model_optimizer/mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolov4.json --batch 1 --reverse_input_channels

Good luck