Download index.html from deee007/Amna: direct link, hf CLI and curl.
- Browser
- Download file 2.07 kB
-
https://huggingface.co/spaces/deee007/Amna/resolve/main/index.html
- Command line
-
hf download hf://spaces/deee007/Amna/index.html
-
curl -L -o index.html https://huggingface.co/spaces/deee007/Amna/resolve/main/index.html
2.07 kB
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <title>Sentiment Analyzer</title> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@stlite/browser@0.85.1/build/stlite.css" /> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@stlite/browser@0.85.1/build/style.css" /> | |
| </head> | |
| <body> | |
| <streamlit-app> | |
| import json | |
| import streamlit as st | |
| from pyodide.code import run_js | |
| from js import JSON | |
| # ONNX copy of cardiffnlp/twitter-roberta-base-sentiment-latest | |
| MODEL = "Xenova/twitter-roberta-base-sentiment-latest" | |
| EMOJI = {"POSITIVE": "π", "NEUTRAL": "π", "NEGATIVE": "π "} | |
| st.set_page_config(page_title="Sentiment Analyzer", page_icon="π") | |
| st.title("Sentiment Analyzer") | |
| st.caption("Paste a sentence or paragraph and the model will score its sentiment.") | |
| if "clf" not in st.session_state: | |
| msg = st.empty() | |
| msg.info("Loading model (first run only, about 126 MB)... please wait.") | |
| try: | |
| mod = await run_js("import('https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.1')") | |
| st.session_state["clf"] = await mod.pipeline("sentiment-analysis", MODEL) | |
| msg.empty() | |
| except Exception as e: | |
| msg.error(f"Could not load model: {e}") | |
| st.stop() | |
| clf = st.session_state["clf"] | |
| text = st.text_area("Your text:", height=150, max_chars=2000) | |
| if st.button("Analyze"): | |
| if not text.strip(): | |
| st.warning("Please type something first.") | |
| else: | |
| try: | |
| raw = await clf(text) | |
| result = json.loads(JSON.stringify(raw))[0] | |
| label = result["label"].upper() | |
| score = result["score"] | |
| st.subheader(f"{EMOJI.get(label, '')} {label}") | |
| st.progress(float(score)) | |
| st.write(f"Confidence: *{score:.0%}*") | |
| except Exception as e: | |
| st.error(f"Something went wrong: {e}") | |
| </streamlit-app> | |
| <script type="module" src="https://cdn.jsdelivr.net/npm/@stlite/browser@0.85.1/build/stlite.js"></script> | |
| </body> | |
| </html> |