---
# System prepended metadata

title: AI server for Training

---

AI server for Training
===
* account : syntec@140.113.150.80
* password : isciagv901
## Environment Preparation
* miniconda setting
    * https://blog.csdn.net/weixin_42066885/article/details/80323173
    * https://github.com/udacity/RoboND-Python-StarterKit/blob/master/doc/configure_via_anaconda.md 
    ```
    conda install pytorch=1.0.1 cudatoolkit=10.0 -c pytorch
    conda install pillow
    conda install pandas
    conda install cython
    conda install scikit-image
    conda install scikit-learn
    conda install torchvision
    conda install pyyaml
    ~~conda install -c conda-forge opencv ~~
    ```
    * 這環境是已經準備好的，不要去改動它
    * 使用方式
        ```
        set_conda
        conda activate opencv_build #啟用
        conda deactivate opencv_build #關閉
        ```
## ESPNetv2
* Execution
    * delete the cached data file (~/ESPNetv2-master/segmentation/city.p)
    ```
    conda activate opencv_build #啟用環境
    CUDA_VISIBLE_DEVICES=0 python3 main.py --s 1.5 #開始訓練
    CUDA_VISIBLE_DEVICES=0 python3 gen_cityscapes.py --s 1.5 --pretrained ./model_best.pth #使用模型 
    ```
    * training主程式 -> main.py / 副程式 -> DataSet.py
    * training dataset資料夾 -> dataSet / training list -> train.txt val.txt
    * trained model儲存資料夾 -> results_espnetv2_xxx / xxx為模型深度參數
    * pre-process
        ```
        mean = [105.07035, 109.71322, 115.14683]
        std = [53.072502, 49.084396, 45.89485 ]
        ```
        * 此參數為圖像的預處理所用，為訓練資料RGB數值的平均值和標準差，驗證模型時gen_cityscapes.py會用到
        
## DenseFusion
* Execution
    ```
    set_conda
    conda activate opencv_build
    cd DenseFusion-Pytorch-1.0/
    
    set -x
    export PYTHONUNBUFFERED="True"
    export CUDA_VISIBLE_DEVICES=0
    python3 ./tools/train_.py --dataset semantics --dataset_root ./datasets/semantics/Semantics_preprocessed #開始訓練
    
    python3 ./tools/eval_semantics.py --dataset_root ./datasets/semantics/Semantics_preprocessed  --model trained_models/semantics/20191206_3000/pose_model_current.pth  --refine_model trained_models/semantics/20191206_3000/pose_refine_model_current.pth #驗證模型
    ``` 
    * DenseFusion這套模型比較複雜，你們要自己創建新的資料夾來進行訓練 -> DenseFusion-Pytorch-1.0/datasets/XXX
    * 如我依照ycb資料集，創建semantics一樣，複製一份semantics資料夾並進行改寫 -> 很麻煩要花時間
    * 所以需改寫train_.py和eval_semantics.py -> 請複製而不要真的去改動原文件
    * 結論:要大量改寫的檔案只有在DenseFusion-Pytorch-1.0/datasets/XXX，每份資料都請認真確認(dataset_config、dataset.py、XXX_preprocessed)，並依需求去改動