質問編集履歴

1

質問文を要約

2022/08/27 05:10

投稿

tkym_1231
tkym_1231

スコア57

test CHANGED
@@ -1 +1 @@
1
- curlコマンドでwavファイルをサーバーにて、処理結果をwavファで受け取りたい
1
+ curlコマンドでバイナリファイル(wavファイルて、処理結果をナリで受け取
test CHANGED
@@ -1,50 +1,44 @@
1
- ### 前提
2
-
3
- Torchserve(ディープラーニングモデルをAPI化するツール)にwavファイルを送信→音声処理→結果をwavファイルで受け取るということを行いたいです。
4
-
5
1
  ### 実現したいこと
6
2
 
7
- - [x] Torchserveにモデルを実装する
8
-  →REST APIで実装されているモデル一覧が表示されていますので、こちらは実施できていると思います。
9
- - [ ] curlコマンドでTorchserveにwavファイルをアップロドして処理する
3
+ curlコマンドでバイナリファイルをバーに転送
10
- - [ ] 処理されたwavファイルを受け取って、ローカルに保存する
4
+ 処理結果を受信し、ローカルに保存
11
5
 
12
- ### 発生している問題・エラーメッセージ
6
+ ### 発生している問題
13
7
 
14
- curlコマンドでwavファイルを送信すると、サーバー側のコンソールに以下のようなエラーが表示されてい
8
+ 以下のようにcurlコマンドでwavファイルを送信した
15
- > curl http://127.0.0.1:8080/predictions/denoise_transformer -T Mix.wav --noproxy '*'
9
+ > curl --data-binary @Mix.wav --noproxy '*' http://127.0.0.1:8080/predictions/denoise_transformer -v
10
+
11
+ すると、以下のような結果が返ってきました。
16
12
 
17
13
  ```
18
- root@0832e168fc4e:~/torchserve-sample# 2022-08-26T14:54:22,088 [INFO ] W-9000-denoise_transformer_1.0 org.pytorch.serve.wlm.WorkerThread - Flushing req. to backend at: 1661493262087
19
- 2022-08-26T14:54:22,089 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - Backend received inference at: 1661493262
20
- 2022-08-26T14:54:22,090 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - Invoking custom service failed.
21
- 2022-08-26T14:54:22,091 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - Traceback (most recent call last):
22
- 2022-08-26T14:54:22,091 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - File "/usr/local/lib/python3.8/dist-packages/ts/service.py", line 102, in predict
23
- 2022-08-26T14:54:22,091 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - ret = self._entry_point(input_batch, self.context)
24
- 2022-08-26T14:54:22,092 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - File "/tmp/models/ddffa2eabca04d7da05948b67b3cd833/model_handler.py", line 72, in handle
25
- 2022-08-26T14:54:22,092 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - model_input = self.preprocess(data)
26
- 2022-08-26T14:54:22,093 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - File "/tmp/models/ddffa2eabca04d7da05948b67b3cd833/model_handler.py", line 51, in preprocess
27
- 2022-08-26T14:54:22,093 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - audio_data, rate = soundfile.read(data)
28
- 2022-08-26T14:54:22,093 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - File "/usr/local/lib/python3.8/dist-packages/soundfile.py", line 256, in read
29
- 2022-08-26T14:54:22,094 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - with SoundFile(file, 'r', samplerate, channels,
30
- 2022-08-26T14:54:22,094 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - File "/usr/local/lib/python3.8/dist-packages/soundfile.py", line 629, in __init__
31
- 2022-08-26T14:54:22,095 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - self._file = self._open(file, mode_int, closefd)
32
- 2022-08-26T14:54:22,095 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - File "/usr/local/lib/python3.8/dist-packages/soundfile.py", line 1182, in _open
33
- 2022-08-26T14:54:22,096 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - raise TypeError("Invalid file: {0!r}".format(self.name))
34
- 2022-08-26T14:54:22,100 [INFO ] W-9000-denoise_transformer_1.0 org.pytorch.serve.wlm.WorkerThread - Backend response time: 11
35
- 2022-08-26T14:54:22,100 [INFO ] W-9000-denoise_transformer_1.0 ACCESS_LOG - /127.0.0.1:54256 "PUT /predictions/denoise_transformer HTTP/1.1" 503 13
36
- 2022-08-26T14:54:22,100 [INFO ] W-9000-denoise_transformer_1.0 TS_METRICS - Requests5XX.Count:1|#Level:Host|#hostname:0832e168fc4e,timestamp:1661487724
37
- 2022-08-26T14:54:22,100 [DEBUG] W-9000-denoise_transformer_1.0 org.pytorch.serve.job.Job - Waiting time ns: 97479, Inference time ns: 12537448
38
- 2022-08-26T14:54:22,100 [INFO ] W-9000-denoise_transformer_1.0 TS_METRICS - WorkerThreadTime.ms:2|#Level:Host|#hostname:0832e168fc4e,timestamp:1661493262
39
- 2022-08-26T14:54:22,101 [INFO ] W-9000-denoise_transformer_1.0-stdout MODEL_LOG - TypeError: Invalid file: [{'body': bytearray(b'RIFF&\xf4\x01\x00WAVEfmt \x12\x00\x00\x00\x01\x00\x01\x00\x80>\x00\x00\x00}\x00\x00\x02\x00\x10\x00\x00\x00data\x00\xf4\x01\x00\x01\x00\xbd\xffq\xff\xc6\xff\xb9\xff\xed\xff\xe8\xff\r\x005\x008\x00\x87\x00d\x00\xa5\x00\x8a\x00\xb0\x00\x9c\x00\xbf\x00\x91\x00\xbd\x00`\x00\x9d\x00\x0f\x00B\x00\x93\xff\xc4\xffb\xff\xc9\xffZ\xff\xdd\xff\x16\xff\xde\xff\x9a\xfd(\xee\xe1\xf3\xf0\xf5.\xfa\xe8\xfc\xb7\xfd\xaa\x05\xb8\x04\xec\r\x8a\x0e3\x11\xfa\x14X\x138\x17&\x16\xd8\x16\x9a\x16\xd5\x12\x11\x12\xcd\x0b\x88\x06\xb1\xfe\x15\xf4a\xf2\xd0\xf1\x00\xf1\x99\xf3\xb9\xee\x07\xec\xe5\xe7\xa2\xe4\xcf\xe94\xe9L\xf0r\xf5\x96\xf61\xfd\xa5\xfb-\x02V\x05h\x08q\x10\xe2\x0e\x99\x14^\x14\xa8\x15l\x184\x16F\x18\xe2\x14\xf6\x12\xfd\x0f\xfd\x08\x84\x03b\xf9\x9b\xf1\x9d\xf2U\xf0\xf5\xf15\xf2Y\xebw\xea\x80\xe4\xb9\xe69\xea\x9d\xeaG\xf4>\xf5x\xf9F\xfd\x18\xfdw\x056\x05\xab\x0c\xdc\x0fn\x10Y\x16\x1a\x14C\x18J\x17Q\x17n\x17\x18\x135\x12\xad\x0c8\x07\xff\xff.\xf53\xf1\x90\xf1\xfd\xef\xe7\xf21\xef\xa0\xead\xe8\xc6\xe3\x10\xe9"\xe9j\xee\xb6\xf5\xd1\xf5\xa0\xfc\xc8\xfb\x93\x00\xed\x053\x07\x1c\x10\x12\x0f\xc5\x13@\x15\x14\x15\xca\x18j\x16g\x18\x96\x15\xdf\x12\x19\x10!\n\xde\x04V\xfb\xa1\xf2\xdc\xf1\x94\xf0\xeb\xf0\xa5\xf21\xec\xa6\xea\x91\xe5\xb7\xe5]\xea\xcc\xe9w\xf3\x9f\xf5\xca\xf8N\xfd2\xfca\x04\x8e\x05)\x0c\x8f\x10\x8b\x10\xf5\x15E\x14\xab\x17\xbc\x17.\x17\x15\x18=\x14\xc5\x12\xc9\r\xb0\x07\xb4\x00\x12\xf6\xfb\xf14\xf2\xf1\xefZ\xf3Q\xef\xd8\xea@\xe8\x96\xe3^\xe9.\xe9\x8f\xee_\xf5\xbb\xf5\x91f\x00.\x00$\x00 \x00\x13\x00\xfa\xff\xf1\xff\xe3\xff\xd9\xff\xd6\xff\xd2\xff\xeb\xff\x0f\x00\x15\x00\xfb\xff\xef\xff\x08\x00&\x00(\x00 \x00\xfe\xff\xc6\xff\xbd\xff\xbb\xff\xc3\xff\xde\xff\xdd\xff\xda\xff\xbb\xff\x9e\xff\xb7\xff\xe5\xff\x1c\x00 \x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')}]
14
+ * Trying 127.0.0.1...
15
+ * TCP_NODELAY set
16
+ * Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
17
+ > POST /predictions/denoise_transformer HTTP/1.1
18
+ > Host: 127.0.0.1:8080
19
+ > User-Agent: curl/7.58.0
20
+ > Accept: */*
21
+ > Content-Length: 128046
22
+ > Content-Type: application/x-www-form-urlencoded
23
+ > Expect: 100-continue
24
+ >
25
+ < HTTP/1.1 100 Continue
26
+ * We are completely uploaded and fine
27
+ < HTTP/1.1 500 Internal Server Error
28
+ < content-type: application/json
29
+ < x-request-id: 5057cd2e-b0ce-4155-a05f-9d2d39d8a8ef
30
+ < Pragma: no-cache
31
+ < Cache-Control: no-cache; no-store, must-revalidate, private
32
+ < Expires: Thu, 01 Jan 1970 00:00:00 UTC
33
+ < content-length: 89
34
+ < connection: close
35
+ <
36
+ {
37
+ "code": 500,
38
+ "type": "ErrorDataDecoderException",
39
+ "message": "Bad end of line"
40
+ }
41
+ * Closing connection 0
40
42
  ```
41
43
 
42
- ### 補足情報(FW/ツールのバージョンなど)
43
-
44
- OS:Ubuntu 18.04
45
- torch:1.12.1+cu113
46
- torchserve:0.6.0
47
-
48
- 以下のサ参考にていま。こちらで紹介されてるサンプルは動作させることが出来た。
44
+ そもそもcurlコマンドでバナリファイル送信、結果をバイナリファイルで受信るとことが出来るのでょうか?
49
- https://qiita.com/tamitarai/items/ef7e785483ad4699a424
50
-