Spaces:
Sleeping
Sleeping
import streamlit as st | |
from config import settings | |
from utils import init_model, custom_predict | |
def main(): | |
st.title("Crypto Market Sentiment Analyzer") | |
raw_text = st.text_area("Enter Text Here", "Type Here, for example - The cryptocurrency market is down today due to Trump's latest restrictions on Nvidia") | |
if st.button("Analyze"): | |
pipe = init_model(settings.TASK, settings.MODEL_NAME) | |
result = custom_predict(raw_text, pipe) | |
label = result[0]["label"] | |
score = result[0]["score"] | |
# Crypto market is Positive (LABEL_1) or Negative (LABEL_0) | |
color = "green" if label == "LABEL_1" else "red" | |
emoji = "😊" if label == "LABEL_1" else "😡" | |
type = "positive" if label == "LABEL_1" else "negative" | |
st.markdown( | |
f"<h3 style='color:{color};'>Sentiment: {type} {emoji} ({score:.1%})</h3>", | |
unsafe_allow_html=True, | |
) | |
st.progress(score) # score от 0.0 до 1.0 | |
st.write(f"Confidence: **{score:.1%}**") | |
if __name__ == "__main__": | |
main() | |