使用Docker安裝detectron2的配置方法
Detectron2 是一個(gè)用于目標(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")
# 進(jìn)行預(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安裝配置MySQL的實(shí)現(xiàn)步驟
MySQL 是最流行的關(guān)系型數(shù)據(jù)庫管理系統(tǒng),在 WEB 應(yīng)用方面 MySQL 是最好的 RDBMS(Relational Database Management System:關(guān)系數(shù)據(jù)庫管理系統(tǒng))應(yīng)用軟件之一。在本教程中,會(huì)帶大家正確安裝配置MySQL在Docker2021-11-11
Docker容器實(shí)現(xiàn)MySQL多源復(fù)制場景分析
這篇文章主要介紹了Docker容器實(shí)現(xiàn)MySQL多源復(fù)制,通過本文學(xué)習(xí)可以掌握多源復(fù)制的好處,通過使用場景分析給大家介紹的非常詳細(xì),需要的朋友可以參考下2022-06-06
Docker 搭建集群MongoDB的實(shí)現(xiàn)步驟
這篇文章主要介紹了Docker 搭建集群MongoDB的實(shí)現(xiàn)步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09
Rocky Linux 9.2下使用dnf安裝Docker全流程指南
Docker 是當(dāng)前最流行的容器化平臺,本文以 Rocky Linux 9.2 為例,詳細(xì)介紹如何使用 dnf 命令安裝 Docker,完成配置并進(jìn)行基礎(chǔ)使用,希望對大家有所幫助2025-08-08
docker 安裝 rocketmq + dashboard的實(shí)現(xiàn)
本文主要介紹了docker 安裝 rocketmq + dashboard的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2026-05-05
在wsl-ubuntu中如何通過 docker 啟動(dòng) gpu-jupyter
這篇文章主要介紹了在wsl-ubuntu中如何通過 docker 啟動(dòng) gpu-jupyter,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2024-01-01
滾動(dòng) docker 中的 nginx 日志思路詳解
Nginx 自己沒有處理日志的滾動(dòng)問題,本文筆者介紹如何滾動(dòng)運(yùn)行在 docker 中的 nginx 日志文件,感興趣的朋友一起看看吧2018-08-08
解決運(yùn)行Docker鏡像報(bào)錯(cuò):version `GLIBC_2.32‘ not found
文章介紹了解決Docker鏡像運(yùn)行時(shí)因GLIBC版本不匹配導(dǎo)致的錯(cuò)誤,建議使用AlpineLinux作為基礎(chǔ)鏡像,并在其中安裝所需的運(yùn)行時(shí)庫,作者還分享了個(gè)人經(jīng)驗(yàn),提醒讀者嘗試其他方法無效后可以尋求幫助2024-12-12

