I defined two gr.File component as input in space, then used the below demo gradio_client code to request space as API
from gradio_client import Client
client = Client('space name', hf_token='...',serialize=False)
result = client.predict(
"/tmp/video.mp4", # str (filepath or URL to file)
in 'Video or Image' File component
"/tmp/audio.mp3", # str (filepath or URL to file)
in 'Audio' File component
fn_index=0
)
print(result)
Error raised on local:
Traceback (most recent call last):
File "/Users/taoluo/Workspace/lorne/gradio-lipsync-wav2lip/gradio_api.py", line 6, in <module>
result = client.predict(
File "/Users/taoluo/Workspace/lorne/gradio-lipsync-wav2lip/venv/lib/python3.9/site-packages/gradio_client/client.py", line 305, in predict
return self.submit(*args, api_name=api_name, fn_index=fn_index).result()
File "/Users/taoluo/Workspace/lorne/gradio-lipsync-wav2lip/venv/lib/python3.9/site-packages/gradio_client/client.py", line 1456, in result
return super().result(timeout=timeout)
File "/opt/homebrew/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 446, in result
return self.__get_result()
File "/opt/homebrew/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
raise self._exception
File "/opt/homebrew/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/taoluo/Workspace/lorne/gradio-lipsync-wav2lip/venv/lib/python3.9/site-packages/gradio_client/client.py", line 1126, in _inner
predictions = _predict(*data)
File "/Users/taoluo/Workspace/lorne/gradio-lipsync-wav2lip/venv/lib/python3.9/site-packages/gradio_client/client.py", line 1156, in _predict
raise ValueError(result["error"])
ValueError: None
And error also raised in space contianer log
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.8.18/lib/python3.8/site-packages/gradio/routes.py", line 488, in run_predict
output = await app.get_blocks().process_api(
File "/home/user/.pyenv/versions/3.8.18/lib/python3.8/site-packages/gradio/blocks.py", line 1428, in process_api
inputs = self.preprocess_data(fn_index, inputs, state)
File "/home/user/.pyenv/versions/3.8.18/lib/python3.8/site-packages/gradio/blocks.py", line 1245, in preprocess_data
processed_input.append(block.preprocess(inputs[i]))
File "/home/user/.pyenv/versions/3.8.18/lib/python3.8/site-packages/gradio/components/file.py", line 218, in preprocess
return process_single_file(x)
File "/home/user/.pyenv/versions/3.8.18/lib/python3.8/site-packages/gradio/components/file.py", line 178, in process_single_file
f["name"],
TypeError: string indices must be integers
Loos like the uploaded file not been processed correctly, How to solve it?
space gradio version: gradio[oauth]==3.40.1 spaces==0.18.0
local gradio_client version: gradio_client==0.4.0