The steps are taken from this video and document with some small changes.
- Install Anaconda. Download it from this link.
cd Downloads/
sudo chmod +x Anaconda3-2021.11-Linux-x86_64.sh
./Anaconda3-2021.11-Linux-x86_64.sh
| """ | |
| Module Docstring. | |
| author:name | |
| date:date | |
| """ | |
| import argparse | |
| import logging |
| # Single underscore | |
| class Example(): | |
| _private_variable = 10 | |
| def __init__(self): | |
| self._private_variable = 20 | |
| example_object = Example() | |
| print(example_object._private_variable) | |
| # Double underscores |
If locate is not installed, install it with:
sudo apt install mlocate. You might get results like:
locate opencv.hpp (py37_test)
/usr/include/boost/compute/interop/opencv.hpp
/usr/include/opencv4/opencv2/opencv.hpp
Ctrl+Shift+P.| import cv2 | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| # To add a colored mask over a image | |
| def add_colored_mask(image, mask): | |
| color = (0, 0, 255) # Red. | |
| image_colored = np.zeros(image.shape, image.dtype) | |
| image_colored[:,:] = color |
| import subprocess | |
| def check_gpu_availability(threshold=50): | |
| # Run the nvidia-smi command to get GPU information | |
| cmd = "nvidia-smi --query-gpu=index,memory.used,memory.total --format=csv,noheader" | |
| gpu_info = subprocess.check_output(cmd, shell=True).decode().strip().split("\n") | |
| # Parse the GPU information into a list of dictionaries | |
| gpu_list = [] | |
| for gpu in gpu_info: |
sudo mkdir -p /<example_dir>/
sudo mv <my_executable_dir> /<example_dir>/
sudo ln -s /<example_dir>/<my_example_dir>/<executable> /usr/local/bin/<executable_name>