|
import requests |
|
import torch |
|
import gradio as gr |
|
|
|
API_URL = "https://api-inference.huggingface.co/models/ProsusAI/finbert" |
|
headers = {"Authorization": "Bearer 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"} |
|
|
|
def query(payload): |
|
response = requests.post(API_URL, headers=headers, text=payload) |
|
return response.text() |
|
|
|
output = query({ |
|
"inputs": "I like you. I love you", |
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict_sentiment, |
|
inputs=[gr.Textbox(lines=2, label="Financial Statement")], |
|
outputs=[ |
|
gr.Textbox(label="Sentiment"), |
|
], |
|
live=True, |
|
title="Financial Content Sentiment Analysis", |
|
description="Enter a financial statement to analyze its sentiment." |
|
) |
|
|
|
iface.launch() |