Yolox 예제 노트북 코드 관련으로 문의 드립니다

위 링크의 예제를 실행하는 중인데.

예제가 3개월 전이어서 그런지
model_quantized = quantize(model, ranges, with_quantize=False)
위 명령문에서 with_quantize 라는 전달인자는 없어진 것 같습니다.
help(quantize) 에서 확인했습니다.

그리고 순서에 따라 다 따라했는데
InvalidInput: Invalid input tensors 오류가 발생합니다.
재부팅도 몇 번이고 했지만 처음에 제대로 되는 것 처럼 진행되다가
위의 오류를 발생 시킵니다.




아래는 출력 내용입니다.

2023-10-12T09:25:37.627607Z  INFO furiosa_rt_core::driver::event_driven::coord: FuriosaRT (v0.10.1, rev: e710d5f8c, built at: 2023-09-22T00:49:24Z) bootstrapping ...
2023-10-12T09:25:37.632500Z  INFO furiosa_rt_core::driver::event_driven::coord: Found furiosa-compiler (v0.10.0, rev: f8f05c8, built at: 2023-08-08T11:58:09Z)
2023-10-12T09:25:37.632516Z  INFO furiosa_rt_core::driver::event_driven::coord: Found libhal (type: warboy, v0.11.0, rev: 43c901f built at: 2023-08-08T12:07:35Z)
2023-10-12T09:25:37.632524Z  INFO furiosa_rt_core::driver::event_driven::coord: [Runtime-0] detected 1 NPU device(s):
2023-10-12T09:25:37.637812Z  INFO furiosa_rt_core::driver::event_driven::coord: - [0] npu:0:0-1 (warboy-b0-2pe, 128dpes, firmware: 1.7.2, e1c4288)
2023-10-12T09:25:37.638377Z  INFO furiosa_rt_core::driver::event_driven::coord: [Runtime-0] started
2023-10-12T09:25:43.778055Z  INFO furiosa::runtime: Saving the compilation log into /home/nobleteam/.local/state/furiosa/logs/compiler-20231012182543-ngxcr7.log
2023-10-12T09:25:43.779059Z  INFO furiosa_rt_core::driver::event_driven::coord: [Runtime-0] created Sess-2ebcf2d1 using npu:0:0-1
2023-10-12T09:25:43.797906Z  INFO furiosa_rt_core::driver::event_driven::coord: [Sess-2ebcf2d1] compiling the model (target: warboy-b0-2pe, 128dpes, size: 216.8 MB)
2023-10-12T09:25:46.525306Z  INFO furiosa_rt_core::driver::event_driven::coord: [Sess-2ebcf2d1] the model compile is successful (took 2 secs)
2023-10-12T09:25:46.636733Z  INFO furiosa_rt_core::driver::event_driven::coord: [Runtime-0] created 1 NPU threads on npu:0:0-1 (DRAM: 65.3 MiB/16.0 GiB, SRAM: 32.0 MiB/128.0 MiB)
2023-10-12T09:25:47.419611Z  INFO furiosa_rt_core::driver::event_driven::coord: [Sess-2ebcf2d1] terminated
2023-10-12T09:25:47.427483Z  INFO furiosa_rt_core::npu::raw: NPU (npu:0:0-1) has been closed
2023-10-12T09:25:47.429732Z  INFO furiosa_rt_core::driver::event_driven::coord: [Runtime-0] stopped
---------------------------------------------------------------------------
InvalidInput                              Traceback (most recent call last)
Cell In[12], line 7
      5 inputs = [preproc(cv2.imread(image), (640, 640))[0][np.newaxis, ...]]
      6 start = time.perf_counter_ns()
----> 7 outputs = session.run(inputs)
      8 elapsed_time += time.perf_counter_ns() - start
      9 total_predictions += 1

InvalidInput: Invalid input tensors

혹시 제가 뭔가를 빠트린 거나 잘못 이해한 게 있나요?
HxWxC, CxHxW, 1xCxHxW 정도는 아는데

def preproc 에서 최적화 적용하기 전(15,16라인 주석처리전)에는
정상적으로 나오는 것을 확인했습니다.

아래는
model_quantized = quantize(model, ranges, with_quantize=False)
위 명령문에서 with_quantize 라는 전달인자는 없어진 것 같습니다.
help(quantize) 에서 확인했습니다.

2 Likes

안녕하세요 FuriosaAI 김종욱입니다.

문의 주신 내용에 대하여 답변을 드리면, SDK 0.9.0 버전에서 지원하였던
with_quantize=False 옵션의 역할은 모델 입력의 자료형을 int8로 받도록 하는 것이었습니다.

따라서 양자화 과정에서 with_quantize=False와 같은 역할을 하는 옵션을 사용하지 않는 경우
16 라인 (입력의 타입을 float으로 변환하는 경우)을 주석처리하는 경우 입력의 타입이 달라져 오류가 발생하게 됩니다.

SDK 0.10.0 에서는 ModelEditor 기능을 통해 동일한 작업을 진행할 수 있으며, 자세한 내용은 아래 참조 부탁드리겠습니다.

https://furiosa-ai.github.io/docs/latest/ko/software/performance.html#quantize

또한 빠른 시일 내에 SDK 0.10.0에 해당하는 예제들로 업데이트하여 불편함이 없도록 하겠습니다.

제가 이해한 걸 정리하면

16라인을 주석 처리한 후에
model = onnx.load_model(“yolox_l.onnx”)
model = optimize_model(model)

====================================================

editor = ModelEditor(model)
input_tensor_name = get_pure_input_names(model)[0] #<<==입력텐서이름찾기

editor.convert_input_type(input_tensor_name, TensorType.UINT8)

====================================================

== 안에 든
위 코드를 이용해서 모델의 입력 타입을 float에서 int8로 바꾸어야한다는 말씀이군요.
답변 감사합니다.

1 Like