栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Install Python3.8.2+PyTorch+Opencv+Sklearn

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Install Python3.8.2+PyTorch+Opencv+Sklearn

Environment

Let’s start to build a development environment.

1.1 Install python

Go to Internet to find Python, which is version 3.8.2. The version of Python is the base stone for every package’s version.

1.2 Install PyCharm

Go to Internet to find PyCharm.

Community edition is free and your computer’s operation system is windows, so download PyCharm-community-2021.3.exe.

During installing PyCharm, you meet a user interface like Figure1-1 and you can follow the configurable options or not. It doesn’t matter.

Figure1-1 Installation Options User Interface

1.3 Install requirement

(1)view Packages in your environment

# open shell and use the command shown below

pip list

(2)Install Packages by requirement.txt
  • requirements.txt

certifi==2022.5.18.1

charset-normalizer==2.0.12

cycler==0.11.0

fonttools==4.33.3

future==0.18.2

idna==3.3

imageio==2.19.3

joblib==1.1.0

kiwisolver==1.4.2

matplotlib==3.5.2

networkx==2.8.2

numpy==1.22.4

opencv-contrib-python==4.1.2.30

packaging==21.3

pandas==1.4.2

Pillow==9.1.1

pyparsing==3.0.9

python-dateutil==2.8.2

pytz==2022.1

PyWavelets==1.3.0

requests==2.27.1

scikit-image==0.19.2

scikit-learn==1.1.0

scipy==1.8.1

six==1.16.0

threadpoolctl==3.1.0

tifffile==2022.5.4

torch==1.5.1+cpu

torchvision==0.6.1+cpu

urllib3==1.26.9

  • command line

# Install by requirements.txt

pip install -r requirements.txt

(3)Install packages in manual mode

Firstly, you should know about mirror from:

更改pip镜像源的多种方法_惜洛-Jankin的博客-CSDN博客_pip更换镜像源

  • Opencv

# Install numpy additionally

pip install opencv-contrib-python==4.1.2.30

  • Pytorch

# CPU only

pip install torch==1.5.1+cpu torchvision==0.6.1+cpu -f https://download.pytorch.org/whl/torch_stable.html

  • Sklearn

# Scikit-learn

pip install -U scikit-learn

# pandas matplotlib

pip install pandas matplotlib

# scikit-image

pip install scikit-image

The minimum version of Scikit-learn dependencies are listed below along with its purpose.

Dependency

Minimum Version

Purpose

numpy

1.17.3

build, install

scipy

1.3.2

build, install

joblib

1.0.0

install

threadpoolctl

2.0.0

install

cython

0.29.24

build

matplotlib

3.1.2

benchmark, docs, examples, tests

scikit-image

0.14.5

docs, examples, tests

pandas

1.0.5

benchmark, docs, examples, tests

seaborn

0.9.0

docs, examples

memory_profiler

0.57.0

benchmark, docs

pytest

5.0.1

tests

pytest-cov

2.9.0

tests

flake8

3.8.2

tests

black

22.3.0

tests

mypy

0.770

tests

pyamg

4.0.0

tests

sphinx

4.0.1

docs

sphinx-gallery

0.7.0

docs

numpydoc

1.2.0

docs, tests

Pillow

7.1.2

docs

sphinx-prompt

1.3.0

docs

sphinxext-opengraph

0.4.2

docs

1.4 Verify Installation
  • Python

Run the command prompt and enter the command line shown below.

Python --version

  • Pytorch

From the command line, type:

Python

then enter the following code:

import torch

x = torch.rand(5, 3)

print(x)
  • Opencv

enter the following code:

import cv2

image = cv2.imread(“image.png”);
  • Sklearn

enter the following code:

from sklearn.ensemble import HistGradientBoostingRegressor

import numpy as np

import matplotlib.pyplot as plt



# Simple regression function for X * cos(X)

rng = np.random.RandomState(42)

X_1d = np.linspace(0, 10, num=2000)

X = X_1d.reshape(-1, 1)

y = X_1d * np.cos(X_1d) + rng.normal(scale=X_1d / 3)



quantiles = [0.95, 0.5, 0.05]

parameters = dict(loss="quantile", max_bins=32, max_iter=50)

hist_quantiles = {

    f"quantile={quantile:.2f}": HistGradientBoostingRegressor(

        **parameters, quantile=quantile

    ).fit(X, y)

    for quantile in quantiles

}



fig, ax = plt.subplots()

ax.plot(X_1d, y, "o", alpha=0.5, markersize=1)

for quantile, hist in hist_quantiles.items():

    ax.plot(X_1d, hist.predict(X), label=quantile)

_ = ax.legend(loc="lower left")

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/947346.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号