Header Ads Widget

Ticker

6/recent/ticker-posts

CentOS 7: cómo instalar el servidor HTTP BASNet

 BASNet HTTP es un contenedor de servicio HTTP para BASNet: código de detección de objetos salientes con reconocimiento de límites

Requisitos:
Python> = 3.6 ( CentOS 7: instalar python36 y python36-pip )

Paso 1:

1
2
3
mkdir ~/photoshop
cd ~/photoshop

Resultado:

1
2
3
4
5
6
7
[root@s126368 photoshop]# git clone https://github.com/cyrildiagne/BASNet-http.git
Cloning into 'BASNet-http'...
remote: Enumerating objects: 34, done.
remote: Counting objects: 100% (34/34), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 34 (delta 13), reused 16 (delta 2), pack-reused 0
Unpacking objects: 100% (34/34), done.

Paso 2:

1
2

Resultado:

1
2
3
4
5
6
[root@s126368 BASNet-http]# git clone https://github.com/NathanUA/BASNet.git
Cloning into 'BASNet'...
remote: Enumerating objects: 204, done.
remote: Total 204 (delta 0), reused 0 (delta 0), pack-reused 204
Receiving objects: 100% (204/204), 1.97 MiB | 0 bytes/s, done.
Resolving deltas: 100% (100/100), done.

Paso 3: descargue basnet.pth en
/home/tutorialspots/Downloads/basnet.pth

Paso 4:

1
2
3
mkdir BASNet/saved_models
mkdir BASNet/saved_models/basnet_bsi
cp /home/tutorialspots/Downloads/basnet.pth BASNet/saved_models/basnet_bsi/

Paso 5:

1
pip3 install torch==0.4.1

Resultado:

1
2
3
4
5
6
[root@s126368 BASNet-http]# pip3 install torch==0.4.1
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting torch==0.4.1
Installing collected packages: torch
Successfully installed torch-0.4.1

Paso 6:

1
pip3 install -r requirements.txt

Resultado:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
dieciséis
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
sesenta y cinco
66
67
68
69
70
[root@s126368 BASNet-http]# pip3 install -r requirements.txt
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting Flask==1.1.1 (from -r requirements.txt (line 1))
Collecting flask-cors==3.0.8 (from -r requirements.txt (line 2))
Collecting gunicorn==19.9.0 (from -r requirements.txt (line 3))
Collecting numpy==1.15.2 (from -r requirements.txt (line 4))
Collecting scikit-image==0.14.0 (from -r requirements.txt (line 5))
Collecting Pillow==6.2.2 (from -r requirements.txt (line 6))
Collecting torchvision==0.2.1 (from -r requirements.txt (line 7))
Collecting itsdangerous>=0.24 (from Flask==1.1.1->-r requirements.txt (line 1))
Requirement already satisfied: Jinja2>=2.10.1 in /usr/local/lib64/python3.6/site-packages (from Flask==1.1.1->-r requirements.txt (line 1))
Collecting Werkzeug>=0.15 (from Flask==1.1.1->-r requirements.txt (line 1))
Collecting click>=5.1 (from Flask==1.1.1->-r requirements.txt (line 1))
Requirement already satisfied: Six in /usr/local/lib/python3.6/site-packages (from flask-cors==3.0.8->-r requirements.txt (line 2))
Collecting scipy>=0.17.0 (from scikit-image==0.14.0->-r requirements.txt (line 5))
Collecting PyWavelets>=0.4.0 (from scikit-image==0.14.0->-r requirements.txt (line 5))
Collecting matplotlib>=2.0.0 (from scikit-image==0.14.0->-r requirements.txt (line 5))
Collecting cloudpickle>=0.2.1 (from scikit-image==0.14.0->-r requirements.txt (line 5))
Collecting dask[array]>=0.9.0 (from scikit-image==0.14.0->-r requirements.txt (line 5))
Collecting networkx>=1.8 (from scikit-image==0.14.0->-r requirements.txt (line 5))
Requirement already satisfied: torch in /usr/local/lib64/python3.6/site-packages (from torchvision==0.2.1->-r requirements.txt (line 7))
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib64/python3.6/site-packages (from Jinja2>=2.10.1->Flask==1.1.1->-r requirements.txt (line 1))
Collecting cycler>=0.10 (from matplotlib>=2.0.0->scikit-image==0.14.0->-r requirements.txt (line 5))
Collecting kiwisolver>=1.0.1 (from matplotlib>=2.0.0->scikit-image==0.14.0->-r requirements.txt (line 5))
    100% |████████████████████████████████| 92kB 6.5MB/s
Collecting certifi>=2020.06.20 (from matplotlib>=2.0.0->scikit-image==0.14.0->-r requirements.txt (line 5))
    100% |████████████████████████████████| 163kB 1.7MB/s
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 (from matplotlib>=2.0.0->scikit-image==0.14.0->-r requirements.txt (line 5))
    100% |████████████████████████████████| 71kB 6.7MB/s
Collecting python-dateutil>=2.1 (from matplotlib>=2.0.0->scikit-image==0.14.0->-r requirements.txt (line 5))
    100% |████████████████████████████████| 235kB 4.1MB/s
Collecting pyyaml (from dask[array]>=0.9.0->scikit-image==0.14.0->-r requirements.txt (line 5))
    100% |████████████████████████████████| 276kB 3.6MB/s
Collecting toolz>=0.8.2; extra == "array" (from dask[array]>=0.9.0->scikit-image==0.14.0->-r requirements.txt (line 5))
    100% |████████████████████████████████| 51kB 6.7MB/s
Collecting decorator>=4.3.0 (from networkx>=1.8->scikit-image==0.14.0->-r requirements.txt (line 5))
Installing collected packages: itsdangerous, Werkzeug, click, Flask, flask-cors, gunicorn, numpy, Pillow, scipy, PyWavelets, cycler, kiwisolver, certifi, pyparsing, python-dateutil, matplotlib, cloudpickle, pyyaml, toolz, dask, decorator, networkx, scikit-image, torchvision
  Found existing installation: numpy 1.19.1
    Uninstalling numpy-1.19.1:
      Successfully uninstalled numpy-1.19.1
  Found existing installation: Pillow 7.2.0
    Uninstalling Pillow-7.2.0:
      Successfully uninstalled Pillow-7.2.0
  Running setup.py install for pyyaml ... done
  Running setup.py install for toolz ... done
Successfully installed Flask-1.1.1 Pillow-6.2.2 PyWavelets-1.1.1 Werkzeug-1.0.1 certifi-2020.6.20 click-7.1.2 cloudpickle-1.5.0 cycler-0.10.0 dask-2.24.0 decorator-4.4.2 flask-cors-3.0.8 gunicorn-19.9.0 itsdangerous-1.1.0 kiwisolver-1.2.0 matplotlib-3.3.1 networkx-2.5 numpy-1.15.2 pyparsing-2.4.7 python-dateutil-2.8.1 pyyaml-5.3.1 scikit-image-0.14.0 scipy-1.5.2 toolz-0.10.0 torchvision-0.2.1

Paso 7: ejecutar el servidor

1
python3 main.py

Resultado:

1
2
3
4
5
6
7
8
9
10
11
12
[root@s126368 BASNet-http]# python3 main.py
Loading BASNet...
Downloading: "https://download.pytorch.org/models/resnet34-333f7ec4.pth" to /root/.torch/models/resnet34-333f7ec4.pth
100.0%
 * Serving Flask app "main" (lazy loading)
 * Environment: development
 * Debug mode: on
INFO:werkzeug: * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
INFO:werkzeug: * Restarting with stat
Loading BASNet...
WARNING:werkzeug: * Debugger is active!
INFO:werkzeug: * Debugger PIN: 286-791-475

Ejemplo:

1
2
3
4
[tutorialspots@s126368 Desktop]$ curl -F "data=@picture.jpg" http://localhost:8080 -o result.png
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  149k  100 12639  100  137k    681   7564  0:00:18  0:00:18 --:--:--     0

Nota:
Obtenemos un archivo de 256 × 256 en lugar del tamaño de mi imagen de entrada. Debe cambiar su tamaño al ancho y alto de su imagen de entrada.

Publicar un comentario

0 Comentarios