콘텐츠로 이동

Installation

1. 환경 설정


설치

레포지토리 클론
SaigeVAD 레포지토리는 SaigeToolKit 서브모듈을 사용하고 있습니다. 아래의 명령어를 이용하여 레포지토리를 클론하고 서브모듈을 다운받을 수 있습니다.

git clone https://SaigeResearch@dev.azure.com/SaigeResearch/Research/_git/SaigeVAD2 -b 2.5.7-alpha2
cd SaigeVAD2
git submodule update --init --recursive
가상환경 설정
conda 환경을 생성합니다.
conda create -n research python=3.8  # 연구팀 공통 conda env
conda activate research

Requirments 설치
아래의 명령어를 이용하여 SaigeVAD와 서브모듈의 requirements를 설치할 수 있습니다. 설치를 위해서는 SaigeError repo의 git credential이 필요합니다.

pip install -r requirements.txt

2. Python API 테스트


API 테스트를 통해 소스코드와 환경이 제대로 설정 되었는지 확인합니다.

python test/test_saigevad_api.py

  • expected results - 각 api의 리턴 값을 확인하실 수 있습니다. (--verbose argument 사용)

    ====================================================================================
    Test with password
    ====================================================================================
    --------------------------------------------------------------------------------
    VadTrainer.build                                              |  PASSED
    error code: 0, Success
    return value: <SaigeVAD.engine.saigevad_api.VadTrainer object at 0x7fd7e443e210>
    --------------------------------------------------------------------------------
    VadTrainer.to_device (0)                                      |  PASSED
    error code: 0, Success
    return value: None
    --------------------------------------------------------------------------------
    VadTrainer.train_one_step                                     |  PASSED
    error code: 0, Success
    return value: {
        "step": 1 (int)
        "epoch": 1 (int)
        "epoch_step": 0 (int)
        "loss/total": 0.8101391196250916 (float)
        "step_time(sec)": 3.6233785152435303 (float)
    }
    --------------------------------------------------------------------------------
    VadTrainer.process_weight_sampling                            |  PASSED
    error code: 0, Success
    return value: [['./test/test_data/211201_CSW_2_________ROI1-vclsonly/20211214_101845_CSW_9-8_______2_211201_CSW_2_________ROI1_1/roi/roi0_228_274_510_464/frame/000000.jpg'
      '0.54576063' '1']
     ['./test/test_data/211201_CSW_2_________ROI1-vclsonly/20211214_101845_CSW_9-8_______2_211201_CSW_2_________ROI1_1/roi/roi0_228_274_510_464/frame/000001.jpg'
      '0.44908392' '1']
     ['./test/test_data/211201_CSW_2_________ROI1-vclsonly/20211214_101845_CSW_9-8_______2_211201_CSW_2_________ROI1_1/roi/roi0_228_274_510_464/frame/000002.jpg'
      '0.65217334' '1']
     ['./test/test_data/211201_CSW_2_________ROI1-vclsonly/20211214_101845_CSW_9-8_______2_211201_CSW_2_________ROI1_1/roi/roi0_228_274_510_464/frame/000003.jpg'
      '0.7324386' '1']]
    --------------------------------------------------------------------------------
    VadTrainer.train_adaptive_autoencoder                         |  PASSED
    error code: 0, Success
    return value: None
    --------------------------------------------------------------------------------
    VadTrainer.warm_up                                            |  PASSED
    error code: 0, Success
    return value: None
    --------------------------------------------------------------------------------
    VadTrainer.save_checkpoint                                    |  PASSED
    error code: 0, Success
    return value: None
    --------------------------------------------------------------------------------
    AnomalyClusteringTrainer.build                                |  PASSED
    error code: 0, Success
    return value: <SaigeVAD.engine.saigevad_api.AnomalyClusteringTrainer object at 0x7fd7e404bb50>
    ...
    

3. 라이브러리 빌드 & API 테스트


원하는 경로에 SaigeVAD 라이브러리를 빌드합니다. 예제에서는 deploy 폴더를 사용합니다.

python setup.py build_ext --build-lib deploy

빌드된 바이너리 라이브러리로 API 테스트를 진행합니다.

python test/test_saigevad_api.py --module_path ./deploy

4. 빌드된 라이브러리 사용


빌드된 바이너리를 import하여 필요한 기능을 사용합니다.

from deploy.SaigeVAD import VadTrainer
...