Spaces:
Running
on
Zero
Image format for api?
Hi!
Trying to use the api for this but I am constantly getting: ValueError: None
The error is so long so here is the top and bottom of it:
Loaded as API: https://hysts-blip2.hf.space β
INFO: 192.168.65.1:52505 - "POST /process_ab_find_split_description/ HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in call
return await self.app(scope, receive, send)
...
File "/usr/local/lib/python3.10/site-packages/gradio_client/client.py", line 1001, in _inner
predictions = _predict(*data)
File "/usr/local/lib/python3.10/site-packages/gradio_client/client.py", line 1044, in _predict
raise ValueError(result["error"])
ValueError: None
This is the code I am using (note I tried to use my own image (pathname and different ways) but even the example one from the api docs there doesnt work.. also tried varying numbers and swapping around 'Nucleus sampling' and 'beam search')
def try_blip_2(screenshot_data, token, supabase):
# client = Client("Sof22/BLIP2", hf_token=token)
client = Client("hysts/BLIP2")
screenshot_image = screenshot_data
# print("screenshot_data is: ", screenshot_data)
result = client.predict(
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", #file(screenshot_image), # filepath in 'parameter_4' Image component
"Nucleus sampling", # "Beam search", Literal['Beam search', 'Nucleus sampling'] in 'Text Decoding Method' Radio component
0.5, # float (numeric value between 0.5 and 1.0) in 'Temperature' Slider component
-1, # float (numeric value between -1.0 and 2.0) in 'Length Penalty' Slider component
1, # float (numeric value between 1.0 and 5.0) in 'Repetition Penalty' Slider component
1, # float (numeric value between 1 and 512) in 'Max Length' Slider component
1, # float (numeric value between 1 and 100) in 'Minimum Length' Slider component
1, # float (numeric value between 1 and 10) in 'Number of Beams' Slider component
0.5, # float (numeric value between 0.5 and 1.0) in 'Top P' Slider component
api_name="/caption"
)
#print(result)
return result
Let me know if there is anything extra I should be providing or if the issue is on my end.. (have also tried with and without the hf_token and with and without file() wrapping the pathname.
Thanks in advance!
Hi
@Sof22
, I think the error is due to the parameters you are using. I think the max_length=1
is the cause of the error. (Maybe I should change the minimum value of max_length
.)
It works if you use the default parameters of this Space:
from gradio_client import Client
client = Client("hysts/BLIP2")
result = client.predict(
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # filepath in 'parameter_4' Image component
"Nucleaus sampling", # Literal['Beam search', 'Nucleus sampling'] in 'Text Decoding Method' Radio component
1, # float (numeric value between 0.5 and 1.0) in 'Temperature' Slider component
1, # float (numeric value between -1.0 and 2.0) in 'Length Penalty' Slider component
1.5, # float (numeric value between 1.0 and 5.0) in 'Repetition Penalty' Slider component
50, # float (numeric value between 1 and 512) in 'Max Length' Slider component
1, # float (numeric value between 1 and 100) in 'Minimum Length' Slider component
5, # float (numeric value between 1 and 10) in 'Number of Beams' Slider component
0.9, # float (numeric value between 0.5 and 1.0) in 'Top P' Slider component
api_name="/caption"
)
print(result)
a red double decker bus with a smiley face