Skip to content

hldbalabala/logo_detection

Repository files navigation

logo detection

This project is based on groundingDINO and clip model.

🛠️ Install

Note:

  1. If you have a CUDA environment, please make sure the environment variable CUDA_HOME is set. It will be compiled under CPU-only mode if no CUDA available.

Please make sure following the installation steps strictly, otherwise the program may produce:

NameError: name '_C' is not defined

If this happened, please reinstalled the groundingDINO by reclone the git and do all the installation steps again.

how to check cuda:

echo $CUDA_HOME

If it print nothing, then it means you haven't set up the path/

Run this so the environment variable will be set under current shell.

export CUDA_HOME=/path/to/cuda-11.3

Notice the version of cuda should be aligned with your CUDA runtime, for there might exists multiple cuda at the same time.

If you want to set the CUDA_HOME permanently, store it using:

echo 'export CUDA_HOME=/path/to/cuda' >> ~/.bashrc

after that, source the bashrc file and check CUDA_HOME:

source ~/.bashrc
echo $CUDA_HOME

In this example, /path/to/cuda-11.3 should be replaced with the path where your CUDA toolkit is installed. You can find this by typing which nvcc in your terminal:

For instance, if the output is /usr/local/cuda/bin/nvcc, then:

export CUDA_HOME=/usr/local/cuda

Installation:

  1. Clone the code repository from GitHub.
git clone https://github.com/hldbalabala/logo_detection.git
  1. Change the current directory to the logo_detection folder.
cd logo_detection/
  1. Install the required dependencies in the current directory.
pip install -e .
  1. Install clip.
pip install git+https://github.com/openai/CLIP.git
  1. Download pre-trained model weights. https://pan.baidu.com/s/1b5LjXebpFQEfTqCa-SdaFA?pwd=abcd
mkdir weights
cd weights
# put groundingdino_swint_ogc.pth and best_model_vitb16.pt in this dir
cd ..

▶️ Demo

Check your GPU ID (only if you're using a GPU)

nvidia-smi

Change CLIP_PTH and CLASS_JSON_PTH to the paths of files 'best_model_vitb16.pt' and 'class_indices.json' in demo/inference_on_a_image.py.

Replace {GPU ID}, image_you_want_to_detect.jpg with appropriate values in the following command

CUDA_VISIBLE_DEVICES={GPU ID} python demo/inference_on_a_image.py  -i image_you_want_to_detect.jpg
 [--cpu-only] # open it for cpu mode

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published