推論時有錯誤

edited August 2021 in Innoserve area

你好,我照著範例做到推論模型時有錯誤

我都是在windows系統中執行

執⾏範例模型的推論

python main.py -t KL520-dme_async_pre_post_host_yolov5

會有以下的錯誤

adding devices....

start kdp host lib....

Task:  KL520-dme_async_pre_post_host_yolov5
Traceback (most recent call last):
  File "main.py", line 140, in <module>
    example_function(dev_idx, user_id)
  File "C:\Users\chris\OneDrive\桌面\耐能AI加速棒\host_lib\python\examples_kl520\dme_async_pre_post_host_yolov5.py", line 100, in user_test
    ret = user_test_single_dme(dev_idx, 5)
  File "C:\Users\chris\OneDrive\桌面\耐能AI加速棒\host_lib\python\examples_kl520\dme_async_pre_post_host_yolov5.py", line 75, in user_test_single_dme
    dme_config = kdp_wrapper.init_dme_config(model_id, 3, image_cfg, image_col=image_source_w, image_row=image_source_h,image_ch = 2,\
TypeError: init_dme_config() got an unexpected keyword argument 'crop_box'


我執行

python main.py -t KL520-cam_dme_async_post_host_yolov5

也出現同樣的錯誤


之後把models_520.nef放到host_lib\input_models\KL520中,修改 cam_dme_asynx_post_yolov5 中的model_file = "../input_models/KL520/models_520.nef" 並執行同樣的指令

python main.py -t KL520-cam_dme_async_post_host_yolov5

也是會有一樣的錯誤

請問該如何解決?謝謝

Comments

  • 請問是原本host_lib_competition內的範例就會有問題嗎? 還是修改後才遇到問題?

    是否有執行過python main.py -t KL520-update_both_fw來更新加速棒韌體?

    若是修改後才有問題,錯誤訊息顯示與init_dme_config相關,此步驟是在設定輸入圖片以及模型相關的參數,有可能是輸入參數與實際上的圖片或模型不一致所造成,可以檢查相關環節,或提供相關檔案或資訊讓我們這邊幫忙確認

  • 你好

    我回去看,發現是更新加速棒韌體的時候有錯誤。我是使用 Zadig 來安裝USB驅動程式,如下圖。先插上加速棒,並開啟 Zadig,偵測到USB ID=3231 0100後,按下Install Driver。

    接著跑更新韌體的指令

    (tf2onnxEnv) C:\Users\chris\OneDrive\桌面\耐能AI加速棒\host_lib\python>python main.py -t KL520-update_both_fw
    

    結果如下圖:

    但我不知道怎麼會有這個問題

  • Hello,

    從燒錄的錯誤訊息來看,你所使用的應該不是競賽專用的host_lib_competition這包專案,其他的host_lib專案內容與使用方法跟競賽的操作手冊可能會有點差異。

    要下載競賽用的內容可以至耐能的教育中心 https://www.kneron.com/tw/support/education-center/

    或直接點擊下載 host_lib_competition.zip

  • 你好

    我重新下載一次 host_lib 後再執行一次,還是會有一樣的錯誤。

    但是我將資料夾路徑改到 "C:/Users/chris" 下,就能成功更新韌體(如下),所以應該是路徑中含有中文的關係。

    但是當我執行下一個指令,還是會有一樣的錯誤如下。(有重插過加速棒)

    (python38) C:\Users\chris\host_lib\python>python main.py -t KL520-dme_async_pre_post_host_yolov5
    adding devices....
    
    
    start kdp host lib....
    
    
    Task:  KL520-dme_async_pre_post_host_yolov5
    Traceback (most recent call last):
      File "main.py", line 140, in <module>
        example_function(dev_idx, user_id)
      File "C:\Users\chris\host_lib\python\examples_kl520\dme_async_pre_post_host_yolov5.py", line 100, in user_test
        ret = user_test_single_dme(dev_idx, 5)
      File "C:\Users\chris\host_lib\python\examples_kl520\dme_async_pre_post_host_yolov5.py", line 75, in user_test_single_dme
        dme_config = kdp_wrapper.init_dme_config(model_id, 3, image_cfg, image_col=image_source_w, image_row=image_source_h,image_ch = 2,\
    TypeError: init_dme_config() got an unexpected keyword argument 'crop_box'
    


  • Try "pip install Pillow"

  • (python38) C:\Users\chris\host_lib\python>pip install Pillow
    Requirement already satisfied: Pillow in c:\users\chris\anaconda3\envs\python38\lib\site-packages (8.3.1)
    
    
    (python38) C:\Users\chris\host_lib\python>python main.py -t KL520-dme_async_pre_post_host_yolov5
    adding devices....
    
    
    start kdp host lib....
    
    
    Task:  KL520-dme_async_pre_post_host_yolov5
    Traceback (most recent call last):
      File "main.py", line 140, in <module>
        example_function(dev_idx, user_id)
      File "C:\Users\chris\host_lib\python\examples_kl520\dme_async_pre_post_host_yolov5.py", line 100, in user_test
        ret = user_test_single_dme(dev_idx, 5)
      File "C:\Users\chris\host_lib\python\examples_kl520\dme_async_pre_post_host_yolov5.py", line 75, in user_test_single_dme
        dme_config = kdp_wrapper.init_dme_config(model_id, 3, image_cfg, image_col=image_source_w, image_row=image_source_h,image_ch = 2,\
    TypeError: init_dme_config() got an unexpected keyword argument 'crop_box'
    


    你好 還是會有一樣的錯誤

  • 看你的環境應該是用anaconda,是否可以在你python38環境下透過指令 conda list 列出所有安裝的library

    主要是想確認下面指令所安裝的版本是否正確

    pip install kdp_host_api-x.x.x_win_-py3-none-any.whl
    或
    pip install kdp_host_api-1.0.0_win_-py3-none-any.whl
    


  • 你好,以確認conda list裡面有kdp-host

    kdp-host-api              x.x.x-win-               pypi_0    pypi
    


  • 從錯誤訊息的行數與原始範例的行數不同來看,想請問是否有做過哪些修改? 還是下載host_lib_competition.zip後完全沒修改就會有問題?

    另外,從 TypeError: init_dme_config() got an unexpected keyword argument 'crop_box' 推測,可能是crop_box參數沒有設定好,又因為範例中的crop_box是透過換行符號"\"到下一行,可以試著移除換行符號後改寫在同一行,如下

    dme_config=kdp_wrapper.init_dme_config(model_id,3,image_cfg,image_col=image_source_w,image_row=image_source_h,image_ch= 2,crop_box=crop_box)

    若還是有一樣的問題的話,還請提供dme_async_pre_post_host_yolov5.py與kdp_wrapper.py兩個檔案方便我們這邊確認


    另外,也想確認,是否有跑過範例 "python main.py -t KL520-cam_dme_async_post_host_yolov5",能否正常執行呢?

  • 你好,我把換行符號去掉改寫在同一行也是有一樣的錯誤。

    附檔是dme_async_pre_post_host_yolov5.py 與 `kdp_wrapper.py`

    也有跑過python main.py -t KL520-cam_dme_async_post_host_yolov5,不能執行

  • edited September 2021

    比對你所提供的dme_and_kdp.rar後發現兩個檔案並非出自於同一個專案,dme_async_pre_post_host_yolov5.py 是host_lib_competition.zip內的範例,但kdp_wrapper.py是https://github.com/kneron/host_lib內的檔案,雖然檔名一樣,但因為是不同專案所以不能混在一起用

    同樣都是kdp_wrapper.py內的函式init_dme_config(),競賽內的範例應該要搭配的函式如下,會需要crop_box這個引數,

    def init_dme_config(model_id, output_num, image_format, image_col=constants.IMAGE_SOURCE_W_DEFAULT,  image_row=constants.IMAGE_SOURCE_H_DEFAULT, image_ch=3, ext_param=[0.0],  crop_box = (0,constants.IMAGE_SOURCE_H_DEFAULT,0,constants.IMAGE_SOURCE_W_DEFAULT)):

    但你放在github上的專案跑的話,專案內的函式並沒有crop_box這個引數,所以才會有錯誤

    def init_dme_config(model_id, output_num, image_format, image_col=constants.IMAGE_SOURCE_W_DEFAULT,  image_row=constants.IMAGE_SOURCE_H_DEFAULT, image_ch=3, ext_param=[0.0]):

    還請不要將範例單獨複製到別的專案,統一使用host_lib_competition.zip再試試看

  • 你好,我把host_lib換成host_lib_competition.zip後,就可以成功執行了,謝謝!

The discussion has been closed due to inactivity. To continue with the topic, please feel free to post a new discussion.