Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions anylabeling/services/auto_labeling/yolov5.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def __init__(self, model_config, on_message) -> None:
raise Exception(f"Model not found: {model_abs_path}")

self.net = cv2.dnn.readNet(model_abs_path)
self.net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
self.net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
self.classes = self.config["classes"]

def pre_process(self, input_image, net):
Expand Down
2 changes: 1 addition & 1 deletion anylabeling/views/labeling/label_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def save(
if flags is None:
flags = {}
data = dict(
version=__version__,
#version=__version__,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge with the latest master. I have fixed this issue. Thanks.

flags=flags,
shapes=shapes,
imagePath=image_path,
Expand Down
66 changes: 66 additions & 0 deletions opencv_dnn.sh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file is not necessary because it cannot cover well on different machines.
Please remove this file. We will create a documentation site in the future for installation guide.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Most of the steps were done following this: https://pyimagesearch.com/2020/02/03/how-to-use-opencvs-dnn-module-with-nvidia-gpus-cuda-and-cudnn/

# Download openCV and create your environment:
cd ~
mkdir .opencv_drivers
cd .opencv_drivers/
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.6.0.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.6.0.zip
unzip opencv.zip
unzip opencv_contrib.zip
mv opencv-4.6.0 opencv
mv opencv_contrib-4.6.0 opencv_contrib
mkvirtualenv opencv_cuda
pip install numpy
cd opencv
mkdir build
cd build

# IMPORTANT!: CUDA_ARCH_BIN version must be seen here: https://developer.nvidia.com/cuda-gpus
# I got RTX 2060, so in my case CUDA_ARCH_BIN=7.5
# gcc version > 8 are not supported so set CMAKE_C_COMPILER=/usr/bin/gcc-8

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D WITH_CUDA=ON \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D CUDA_ARCH_BIN=7.5 \
-D WITH_CUBLAS=1 \
-D OPENCV_EXTRA_MODULES_PATH=~/.opencv_drivers/opencv_contrib/modules \
-D HAVE_opencv_python3=ON \
-D PYTHON_EXECUTABLE=~/.virtualenvs/opencv_cuda/bin/python \
-D BUILD_EXAMPLES=ON \
-D CMAKE_C_COMPILER=/usr/bin/gcc-8 ..

# Compile your openCV built before
make -j12
sudo make install
sudo ldconfig


# ln -s command is used to create a symbolic link, also known as a symlink or soft link
cd ~/.virtualenvs/opencv_cuda/lib/python3.8/site-packages/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe other users do not have ~/.virtualenvs as you.

ln -s /usr/local/lib/python3.8/site-packages/cv2/python-3.8/cv2.cpython-38-x86_64-linux-gnu.so cv2.so

# Install all requirements for anylabeling
pip install -r requirements.txt
pip install -r requirements-dev.txt

# Uninstall openCV dependencies, since dnn module installed from source is not recognize by pip
pip uninstall opencv-contrib-python-headless opencv-python-headless


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not add too many new lines in the end.
1 is enough.









2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ PyYAML==6.0
colorama==0.4.5
onnx==1.13.1
onnxruntime==1.14.1
qimage2ndarray==1.10.0
qimage2ndarray==1.10.0