nadzo commited on
Commit
27cda04
·
verified ·
1 Parent(s): 9d7ed7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,22 +1,22 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load the financial sentiment model
5
  sentiment_pipeline = pipeline(
6
- "sentiment-analysis",
7
- model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis"
 
8
  )
9
 
10
  def analyze(text):
11
  result = sentiment_pipeline(text)[0]
12
- return {"label": result["label"], "score": result["score"]} # Return a JSON-serializable dictionary
13
 
14
- # Configure Gradio with explicit API support
15
  gr.Interface(
16
  fn=analyze,
17
  inputs=gr.Textbox(placeholder="Enter crypto news headline..."),
18
- outputs=gr.JSON(), # Use JSON output for API compatibility
19
- title="Crypto News Sentiment Analysis",
20
  flagging_mode="never"
21
  ).launch(
22
  server_name="0.0.0.0",
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the crypto-specific sentiment model
5
  sentiment_pipeline = pipeline(
6
+ "text-classification",
7
+ model="ElKulako/cryptobert", # Crypto-optimized model
8
+ tokenizer="ElKulako/cryptobert"
9
  )
10
 
11
  def analyze(text):
12
  result = sentiment_pipeline(text)[0]
13
+ return {"label": result["label"], "score": result["score"]}
14
 
 
15
  gr.Interface(
16
  fn=analyze,
17
  inputs=gr.Textbox(placeholder="Enter crypto news headline..."),
18
+ outputs=gr.JSON(),
19
+ title="Crypto-Specific Sentiment Analysis",
20
  flagging_mode="never"
21
  ).launch(
22
  server_name="0.0.0.0",