str representing output in 'value_3' Textbox component,
filepath representing output in 'value_11' Image component,
)
api_name: /http_bot
copy
from gradio_client import Client
client = Client("https://liuhaotian-llava-1-6.hf.space/--replicas/9t9d8/")
result = client.predict(
null, # Literal[] in 'parameter_10' Dropdown component
0, # float (numeric value between 0.0 and 1.0) in 'Temperature' Slider component
0, # float (numeric value between 0.0 and 1.0) in 'Top P' Slider component
0, # float (numeric value between 0 and 1024) in 'Max output tokens' Slider component
api_name="/http_bot"
)
print(result)
Return Type(s)
Assistant
To interact with the provided API and get a text response by giving it an image and text input, you should use the /add_text endpoint. This endpoint allows you to submit a piece of text and an image, outputting a chatbot response, the text, and potentially an image. Here's how you can set it up:
Ensure you have the necessary Python modules installed. You'll need gradio_client which interacts with the Gradio API:
pip install gradio_client
User
Assistant
The error you're encountering indicates that the upstream Gradio application has raised an exception, but the error messages are not being displayed in detail because verbose error reporting isn't enabled on the server side. This makes it challenging to understand the exact reason for the failure directly.
str representing output in 'value_3' Textbox component,
filepath representing output in 'value_11' Image component,
)
api_name: /http_bot_1
copy
from gradio_client import Client
client = Client("https://liuhaotian-llava-1-6.hf.space/--replicas/9t9d8/")
result = client.predict(
null, # Literal[] in 'parameter_10' Dropdown component
0, # float (numeric value between 0.0 and 1.0) in 'Temperature' Slider component
0, # float (numeric value between 0.0 and 1.0) in 'Top P' Slider component
0, # float (numeric value between 0 and 1024) in 'Max output tokens' Slider component
api_name="/http_bot_1"
)
print(result)
Return Type(s)
str representing output in 'value_3' Textbox component,
filepath representing output in 'value_11' Image component,
)
api_name: /http_bot_2
copy
from gradio_client import Client
client = Client("https://liuhaotian-llava-1-6.hf.space/--replicas/9t9d8/")
result = client.predict(
null, # Literal[] in 'parameter_10' Dropdown component
0, # float (numeric value between 0.0 and 1.0) in 'Temperature' Slider component
0, # float (numeric value between 0.0 and 1.0) in 'Top P' Slider component
0, # float (numeric value between 0 and 1024) in 'Max output tokens' Slider component
api_name="/http_bot_2"
)
print(result)
Return Type(s)
Literal[] representing output in 'value_10' Dropdown component
How to run this provided re the instructions i want to give image and text and get text as output
Use the /add_text endpoint as described:
Here is an example code snippet adapted from your description:
from gradio_client import Client
# Create a client instance with the specified URL
client = Client("https://liuhaotian-llava-1-6.hf.space/--replicas/9t9d8/")
# Call the predict function with the specified parameters
result = client.predict(
"Hello!!", # Your text input
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # Image input URL
"Crop", # Preprocessing option for the image
api_name="/add_text"
)
# Print out the result
print(result)
Understand the output: The return type of the /add_text API consists of a tuple:
The first element is either a string or a dictionary containing file paths and alt texts, which is the main chatbot response.
The second element is a string response.
The third element could be a file path to an image, if applicable.
Modify as needed: You can change the URL of the image or the textual input to fit your specific use case. The preprocessing option can also be changed between 'Crop', 'Resize', 'Pad', and 'Default' depending on how you want the image processed before being sent.
By running the above script, you should be able to interface with the Gradio API, sending an image and text, and receiving a text response.
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio_client/client.py:476, in Client.predict(self, api_name, fn_index, *args, **kwargs)
458 """
459 Calls the Gradio API and returns the result (this is a blocking call).
460
(...)
471 >> 9.0
472 """
473 self._infer_fn_index(api_name, fn_index)
474 return self.submit(
475 *args, api_name=api_name, fn_index=fn_index, **kwargs
--> 476 ).result()
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio_client/client.py:1509, in Job.result(self, timeout)
1494 def result(self, timeout: float | None = None) -> Any:
1495 """
1496 Return the result of the call that the future represents. Raises CancelledError: If the future was cancelled, TimeoutError: If the future didn't finish executing before the given timeout, and Exception: If the call raised then that exception will be raised.
1497
(...)
1507 >> 9
1508 """
-> 1509 return super().result(timeout=timeout)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py:401, in Future.__get_result(self)
399 if self._exception:
400 try:
--> 401 raise self._exception
402 finally:
403 # Break a reference cycle with the exception in self._exception
404 self = None
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/thread.py:58, in _WorkItem.run(self)
55 return
57 try:
---> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:
60 self.future.set_exception(exc)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio_client/client.py:1128, in Endpoint.make_end_to_end_fn.._inner(*data)
1126 data = self.insert_empty_state(*data)
1127 data = self.process_input_files(*data)
-> 1128 predictions = _predict(*data)
1129 predictions = self.process_predictions(*predictions)
1131 # Append final output only if not already present
1132 # for consistency between generators and not generators
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/gradio_client/client.py:1240, in Endpoint.make_predict.._predict(*data)
1238 if "error" in result:
1239 if result["error"] is None:
-> 1240 raise AppError(
1241 "The upstream Gradio app has raised an exception but has not enabled "
1242 "verbose error reporting. To enable, set show_error=True in launch()."
1243 )
1244 else:
1245 raise AppError(
1246 "The upstream Gradio app has raised an exception: "
1247 + result["error"]
1248 )
AppError: The upstream Gradio app has raised an exception but has not enabled verbose error reporting. To enable, set show_error=True in launch().
Here are a few things you can try to troubleshoot and resolve the issue to improve the chances of your request succeeding:
Check Image URL: Ensure that the image URL you are using is accessible and publicly available. There might be an issue with accessing the given URL from the service.
Adjust Parameters: Double-check that your parameters are being formatted correctly and align them with the expected input types:
Make sure the text exceeds no limitations set by the API.
Verify the exact preprocessing option required by the API ("Crop", "Resize", "Pad", "Default").
Test with Different Inputs: Try using a different image URL or text to see if the problem persists. This can help determine if the issue is with specific input data.
Retry the request: Sometimes, temporary issues can cause a request to fail. Try running the script again after some time.
Contact API Provider: If the issue persists, consider contacting the owner or provider of the API service for more support, especially since the server-side error logging is not enabled, which restricts us from seeing detailed error messages.
Debug Setup: If you have control over the Gradio application, consider enabling detailed error reporting by setting show_error=True in your Gradio app’s launch() method. This will provide more insight into what might be going wrong server-side.
# Example on the server side (if you have access)
import gradio as gr
# Define your Gradio interface here
def my_function():
pass
# Launch with detailed error message enabled
gr.Interface(fn=my_function, ...).launch(show_error=True)
Unfortunately, without verbose error reporting enabled, it's difficult to determine the exact cause of the error from the client side alone. If you don't have access to the Gradio app configurations, you'll need the assistance of someone who does to diagnose the server's issue.