twang15 / Feature-selection

feature-selection algorithm and benchmarks
1 stars 0 forks source link

Imaging: CKD-2nd Paper #16

Open twang15 opened 2 years ago

twang15 commented 2 years ago

Alpha Channel

The alpha channel controls the transparency or opacity of a color. Its value can be represented as a real value, a percentage, or an integer: full transparency is 0.0, 0% or 0, whereas full opacity is 1.0, 100% or 255, respectively.

When a color (source) is blended with another color (background), e.g., when an image is overlaid onto another image, the alpha value of the source color is used to determine the resulting color. If the alpha value is opaque, the source color overwrites the destination color; if transparent, the source color is invisible, allowing the background color to show through. If the value is in between, the resulting color has a varying degree of transparency/opacity, which creates a translucent effect.

The alpha channel is used primarily in alpha blending and alpha compositing.

数字图像:每一个数字图像都是一个像素点矩阵,这个矩阵包含所有像素点的强度值

通道:把图像分解成一个或多个颜色成分

①单通道:一个像素点只需一个数值表示,只能表示灰度,0为黑色

②三通道:RGB模式,把图像分为红绿蓝三个通道,可以表示彩色,全0表示黑色

③四通道:在RGB基础上加上alpha通道,表示透明度,alpha=0表示全透明

深度:深度即位数(比特数)

①位深:一个像素点所占的总位数,也叫像素深度、图像深度等

* 位深 = 通道数 × 每个通道所占位数 

②256色图:n位的像素点可以表示2^n种颜色,称2^n色图,n=8时为256色图

③8位RGB与8位图:前者的位数指每个通道所占的位数,后者指整个像素点共占的位数. 8位RGB是一个24位图,也称为真彩

分辨率:单位英寸所含像素点的个数(长×宽)

twang15 commented 2 years ago

Image segmentation and deep learning

Labelme and imaging classification

Deep learning model training and evaluation

Eliminating the gap between experts and models

twang15 commented 2 years ago

Install paddlepaddle on Lab machine

  1. Reference: https://github.com/PaddlePaddle/PaddleSeg/blob/release/v0.1.0/docs/installation.md

    srun --nodes=1 --ntasks=1 --cpus-per-task=10 --partition=interactive --account=default --time=24:00:00 --pty /bin/bash source ~/.pyenvrc # python 3.9.0

    pip install paddlepaddle-gpu git clone https://github.com/PaddlePaddle/PaddleSeg

    cd PaddleSeg git checkout release/v0.1.0 pip install -r requirements.txt

twang15 commented 2 years ago

PaddleSeg is still under active development. The latest paddleseg version is 2.3.

But in the tutorial, v0.1.0 was used. So we stick to v0.1.0

# 下载预训练模型并进行解压
python pretrained_model/download_model.py unet_bn_coco

# download dataset
python dataset/download_pet.py

# train the model
module load gcc/9.2.0-centos_7
export CUDA_VISIBLE_DEVICES=0
python pdseg/train.py --use_gpu \
                      --do_eval \
                      --use_tb \
                      --tb_log_dir train_log \
                      --cfg configs/unet_pet.yaml \
                      BATCH_SIZE 4 \
                      TRAIN.PRETRAINED_MODEL_DIR pretrained_model/unet_bn_coco \
                      SOLVER.LR 5e-5
twang15 commented 2 years ago
# check python version
[taowang9@smsh11dsu-srcf-d15-36 Project2]$ python -V
Python 3.6.8 :: Anaconda, Inc.

# check CUDA version and Driver version
nvidia-smi

Fri Nov 19 21:40:11 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 460.67 Driver Version: 460.67 CUDA Version: 11.2 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 Quadro P400 On | 00000000:61:00.0 Off | N/A | | 34% 39C P8 N/A / N/A | 1MiB / 2000MiB | 0% Default | | | | N/A | +-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+

# cuDNN 8.1.0 (https://stackoverflow.com/questions/65676873/can-i-install-cudnn-for-cuda-version-11-2) 
# https://stackoverflow.com/questions/65676873/can-i-install-cudnn-for-cuda-version-11-2
# has not been installed on SCG for cuda/11.2.2_460.32.03, so I have to use cuda/10.1.168_418.67_cudNN_7.6.1.34
# cuDNN support matrix: https://docs.nvidia.com/deeplearning/cudnn/support-matrix/index.html

# prepare cuDNN and cuda
module load cuda/10.1.168_418.67_cudNN_7.6.1.34

# follow the installation guide: https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.3/docs/install_cn.md
# install paddlepaddle
python -m pip install paddlepaddle-gpu==2.2.0.post101 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html

# test the installation
# 在您的Python解释器中确认PaddlePaddle安装成功
>>> import paddle
>>> paddle.utils.run_check()

# 确认PaddlePaddle版本
python -c "import paddle; print(paddle.__version__)"

[taowang9@smsh11dsu-srcf-d15-36 tutorial]$ python -c "import paddle; paddle.utils.run_check()" Running verify PaddlePaddle program ... W1119 22:00:30.829879 41167 device_context.cc:447] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 11.2, Runtime API Version: 10.1 W1119 22:00:30.882108 41167 device_context.cc:465] device: 0, cuDNN Version: 7.6. PaddlePaddle works well on 1 GPU. PaddlePaddle works well on 1 GPUs. PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.

如果命令行出现以下提示,说明PaddlePaddle安装成功

# PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
twang15 commented 2 years ago
# install paddleSeg    
git clone https://github.com/PaddlePaddle/PaddleSeg
cd PaddleSeg

[taowang9@smsh11dsu-srcf-d15-36 PaddleSeg]$ git branch -a
* release/2.3
  remotes/origin/HEAD -> origin/release/2.3
  remotes/origin/benchmark
  remotes/origin/develop
  remotes/origin/release/2.1
  remotes/origin/release/2.2
  remotes/origin/release/2.3
  remotes/origin/release/v0.1.0
  remotes/origin/release/v0.2.0
  remotes/origin/release/v0.3.0
  remotes/origin/release/v0.4.0
  remotes/origin/release/v0.5.0
  remotes/origin/release/v0.6.0
  remotes/origin/release/v0.7.0
  remotes/origin/release/v0.8.0
  remotes/origin/release/v2.0
  remotes/origin/release/v2.0.0-rc
  remotes/origin/research
  remotes/origin/revert-1475-pr_branch
  remotes/origin/shiyutang-patch-1

pip install -r requirements.txt

# check installation
python predict.py \
       --config configs/quick_start/bisenet_optic_disc_512x512_1k.yml \
       --model_path https://bj.bcebos.com/paddleseg/dygraph/optic_disc/bisenet_optic_disc_512x512_1k/model.pdparams\
       --image_path docs/images/optic_test_image.jpg \
       --save_dir output/result

W1119 22:06:33.058668 54325 device_context.cc:447] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 11.2, Runtime API Version: 10.1 W1119 22:06:33.058769 54325 device_context.cc:465] device: 0, cuDNN Version: 7.6. 2021-11-19 22:08:27 [INFO] Number of predict images = 1 2021-11-19 22:08:27 [INFO] Loading pretrained model from https://bj.bcebos.com/paddleseg/dygraph/optic_disc/bisenet_optic_disc_512x512_1k/model.pdparams Connecting to https://bj.bcebos.com/paddleseg/dygraph/optic_disc/bisenet_optic_disc_512x512_1k/model.pdparams Downloading model.pdparams [==================================================] 100.00% 2021-11-19 22:08:44 [INFO] There are 356/356 variables loaded into BiSeNetV2. 2021-11-19 22:08:44 [INFO] Start to predict... 1/1 [==============================] - 0s 444ms/step

twang15 commented 2 years ago
### Error

ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/taowang9/.pyenv/versions/3.6.0/lib/python3.6/site-packages/paddle/fluid/core_avx.so)

### solution

module load gcc/9.2.0-centos_7

twang15 commented 2 years ago

How to use PaddlePaddle on SCG

srun --nodes=1 --ntasks=1 --cpus-per-task=10 --partition=interactive --account=default --time=24:00:00 --pty /bin/bash
source env_3_9.sh # enable python 3.9

Running verify PaddlePaddle program ... W1221 15:24:08.769018 41368 device_context.cc:447] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 11.2, Runtime API Version: 10.2 W1221 15:24:08.777760 41368 device_context.cc:465] device: 0, cuDNN Version: 7.6. PaddlePaddle works well on 1 GPU. PaddlePaddle works well on 1 GPUs. PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.