runtime error Exit code: 1. Reason: Fetching model from:…
- User
runtime error Exit code: 1. Reason: Fetching model from: https://huggingface.co/ProsusAI/finbert Caching examples at: '/home/user/app/gradio_cached_examples/13' Caching example 1/1 Traceback (most recent call last): File "/home/user/app/app.py", line 9, in inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text to analyze..."), AttributeError: module 'gradio' has no attribute 'inputs' Container logs:
===== Application Startup at 2024-10-04 11:17:22 =====
Fetching model from: https://huggingface.co/ProsusAI/finbert Caching examples at: '/home/user/app/gradio_cached_examples/13' Caching example 1/1 Traceback (most recent call last): File "/home/user/app/app.py", line 9, in inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text to analyze..."), AttributeError: module 'gradio' has no attribute 'inputs'
pythonimport gradio as gr # Load the FinBERT model using Gradio's shortcut for Hugging Face models finbert = gr.load("models/ProsusAI/finbert") # Create and launch the Gradio interface interface = gr.Interface( fn=finbert, inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text to analyze..."), outputs="label", title="Financial Sentiment Analysis with FinBERT", description="Enter financial news or text to analyze its sentiment using the FinBERT model." ) interface.launch() - Assistant
The error you are encountering,
AttributeError: module 'gradio' has no attribute 'inputs', suggests that there is a mismatch between the Gradio API you're using in your code and the version of the Gradio library you have installed. As of Gradio version 3.0, the API has undergone some changes, andgr.inputsandgr.outputshave been deprecated in favor of using more streamlined components.Here's an updated version of your code that should work with the newer Gradio API:
python - User
===== Application Startup at 2024-10-04 11:18:59 =====
Fetching model from: https://huggingface.co/ProsusAI/finbert Caching examples at: '/home/user/app/gradio_cached_examples/13' Caching example 1/1 Running on local URL: http://0.0.0.0:7860
To create a public link, set
share=Trueinlaunch(). Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/gradio/queueing.py", line 536, in process_events response = await route_utils.call_process_api( File "/usr/local/lib/python3.10/site-packages/gradio/route_utils.py", line 322, in call_process_api output = await app.get_blocks().process_api( File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1945, in process_api data = await self.postprocess_data(block_fn, result["prediction"], state) File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1768, in postprocess_data prediction_value = block.postprocess(prediction_value) File "/usr/local/lib/python3.10/site-packages/gradio/components/label.py", line 134, in postprocess sorted_pred = sorted( TypeError: '<' not supported between instances of 'str' and 'list' Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/gradio/queueing.py", line 536, in process_events response = await route_utils.call_process_api( File "/usr/local/lib/python3.10/site-packages/gradio/route_utils.py", line 322, in call_process_api output = await app.get_blocks().process_api( File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1945, in process_api data = await self.postprocess_data(block_fn, result["prediction"], state) File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1768, in postprocess_data prediction_value = block.postprocess(prediction_value) File "/usr/local/lib/python3.10/site-packages/gradio/components/label.py", line 134, in postprocess sorted_pred = sorted( TypeError: '<' not supported between instances of 'str' and 'list' - Assistant
- User
Write full code
- Assistant
- User
Model Output: {'label': 'neutral', 'confidences': [{'label': 'neutral', 'confidence': 0.8508198261260986}, {'label': 'positive', 'confidence': 0.11472416669130325}, {'label': 'negative', 'confidence': 0.0344560369849205}]} Model Output: {'label': 'neutral', 'confidences': [{'label': 'neutral', 'confidence': 0.8683702945709229}, {'label': 'negative', 'confidence': 0.10249213129281998}, {'label': 'positive', 'confidence': 0.029137592762708664}]}
Invalid Output Format
- Assistant