安装miniconda

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash ./Miniconda3-latest-Linux-x86_64.sh -b -u -p ~/miniconda3

mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh

然后

~/miniconda3/bin/conda init bash

查看可用的虚拟环境

conda env list

创建新的虚拟环境

conda create -n python311 python=3.11

激活新的环境

conda activate python311

安装yolov8

pip install ultralytics

安装onnxruntime

pip install onnxruntime

安装torch

pip install torch torchvision torchaudio

命令行推理

yolo predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg'

各种模型下载地址:
https://github.com/ultralytics/assets/releases/tag/v0.0.0

编译opencv4.8.1

wget https://github.com/opencv/opencv/archive/refs/tags/4.8.1.zip
wget https://github.com/opencv/opencv_contrib/archive/refs/tags/4.8.1.zip

unzip opencv-4.8.1.zip 
unzip opencv_contrib-4.8.1.zip

docker pull ubuntu:22.04
docker ps -a
docker run -itd ubuntu:22.04 /bin/bash

ee82839b65bb0c9cbb02079c7df4068ff76df9eab3e5a95674491a5fa118d453

docker cp opencv-4.8.1.zip ee:/home/hesy
docker cp opencv_contrib-4.8.1.zip ee:/home/hesy

docker exec -it ee /bin/bash

在docker中操作.

cd /home/hesy
unzip opencv-4.8.1.zip 
unzip opencv_contrib-4.8.1.zip 
mkdir build && cd build
cmake ../opencv-4.8.1 -G Ninja -DCMAKE_INSTALL_PREFIX=/home/hesy/opencv481 -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.8.1/modules
ninja -j8
ninja install

opencv测试示例:

#include "bits/stdc++.h"
#include <opencv2/opencv.hpp>
using namespace std;   
int main(int argc, char* argv[]){
   printf("Hello World\n");
   cout<<CV_VERSION<<endl;
   return 0;
 }    
本文链接地址:https://const.net.cn/780.html

标签: none

添加新评论