使用Docker安裝detectron2的配置方法
Detectron2 是一個用于目標(biāo)檢測、分割和其他視覺識別任務(wù)的平臺。
Detectron2 官網(wǎng)安裝教程是基于 linux 安裝的,在 windows 上直接安裝有很多問題,下面采用 docker 方式在 windows 上安裝。
拉取cuda116鏡像
docker pull nvcr.io/nvidia/cuda:11.6.1-cudnn8-devel-ubuntu20.04
創(chuàng)建容器
docker run --gpus=all -it --name ernerf -v D:\Projects\ER-NeRF:/ernerf nvcr.io/nvidia/cuda:11.6.1-cudnn8-devel-ubuntu20.04
安裝依賴環(huán)境
apt-get update -yq --fix-missing \ && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \ pkg-config \ wget \ cmake \ curl \ git \ vim
安裝Miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh sh Miniconda3-latest-Linux-x86_64.sh -b -u -p ~/miniconda3 ~/miniconda3/bin/conda init source ~/.bashrc
創(chuàng)建環(huán)境
conda create -n detectron python=3.10 conda activate detectron
安裝依賴庫
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113 pip install cython opencv-python opencv-python-headless
安裝detectron2
git clone https://github.com/facebookresearch/detectron2.git pip install -e detectron2
調(diào)用示例
from detectron2.config import get_cfg from detectron2 import model_zoo from detectron2.engine import DefaultPredictor from detectron2.utils.visualizer import Visualizer from detectron2.data import MetadataCatalog import cv2 # 加載配置文件 cfg = get_cfg() cfg.merge_from_file(model_zoo.get_config_file("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml")) cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5 # 設(shè)置閾值 cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml") # 創(chuàng)建預(yù)測器 predictor = DefaultPredictor(cfg) # 加載圖像 im = cv2.imread("./image.jpg") # 進行預(yù)測 outputs = predictor(im) # 可視化預(yù)測結(jié)果 v = Visualizer(im[:, :, ::-1], MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale=1.2) v = v.draw_instance_predictions(outputs["instances"].to("cpu")) cv2.imwrite('./output.jpg', v.get_image()[:, :, ::-1])
到此這篇關(guān)于使用Docker安裝detectron2的文章就介紹到這了,更多相關(guān)Docker安裝detectron2內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
docker配置pytorch環(huán)境來進行訓(xùn)練的方法步驟
本文主要介紹了docker配置pytorch環(huán)境來進行訓(xùn)練的方法步驟,從零開始配置,包括換源,安裝下載,具有一定的參考價值,感興趣的可以了解一下2024-03-03使用Jenkins+docker打包部署后端服務(wù)的實現(xiàn)
本文主要介紹了使用Jenkins+docker打包部署后端服務(wù)的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08Docker暴露2375端口導(dǎo)致服務(wù)器被攻擊問題及解決方法
這篇文章主要介紹了Docker暴露2375端口導(dǎo)致服務(wù)器被攻擊問題及解決方法,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-04-04IntelliJ IDEA(2018版)安裝docker插件的詳細(xì)過程
這篇文章主要介紹了IntelliJ IDEA安裝docker插件的詳細(xì)過程,開發(fā)工具使用的是IDEA2018.16版,本文通過圖文實例相結(jié)合給大家介紹的非常詳細(xì),需要的朋友可以參考下2021-09-09docker 部署prometheus+grafana的過程詳解
這篇文章主要介紹了docker 部署prometheus+grafana的過程,本文通過示例圖文相結(jié)合給大家介紹的非常詳細(xì),需要的朋友可以參考下2024-03-03Docker 容器監(jiān)控原理及 cAdvisor的安裝與使用說明
這篇文章主要介紹了Docker 容器監(jiān)控原理及 cAdvisor的安裝與使用說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11docker?mysql關(guān)于配置文件、連接客戶端、/docker-entrypoint-initdb.d/目錄的使用
這篇文章主要介紹了docker?mysql關(guān)于配置文件、連接客戶端、/docker-entrypoint-initdb.d/目錄的使用,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-05-05