Files changed (6) hide show
  1. .gitattributes +35 -0
  2. Dockerfile +13 -13
  3. README.md +12 -9
  4. app.py +0 -36
  5. requirements.txt +3 -3
  6. src/streamlit_app.py +40 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
Dockerfile CHANGED
@@ -1,20 +1,20 @@
1
- # Use the official Python 3.9 image
2
- FROM python:3.9-slim
3
 
4
- # Set the working directory
5
- WORKDIR /code
6
 
7
- # Copy the requirements file
8
- COPY ./requirements.txt /code/requirements.txt
 
 
 
9
 
10
- # Install the dependencies
11
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
 
13
- # Copy the rest of the application code
14
- COPY . /code
15
 
16
- # Expose the default Streamlit port
17
  EXPOSE 8501
18
 
19
- # Command to run the application
20
- CMD ["streamlit", "run", "app.py", "--server.address", "0.0.0.0", "--server.port", "7860"]
 
 
1
+ FROM python:3.13.5-slim
 
2
 
3
+ WORKDIR /app
 
4
 
5
+ RUN apt-get update && apt-get install -y \
6
+ build-essential \
7
+ curl \
8
+ git \
9
+ && rm -rf /var/lib/apt/lists/*
10
 
11
+ COPY requirements.txt ./
12
+ COPY src/ ./src/
13
 
14
+ RUN pip3 install -r requirements.txt
 
15
 
 
16
  EXPOSE 8501
17
 
18
+ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
19
+
20
+ ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
README.md CHANGED
@@ -1,17 +1,20 @@
1
  ---
2
  title: Sentiment Analysis App
3
- emoji: 🤖
4
- colorFrom: blue
5
- colorTo: indigo
6
  sdk: docker
7
- # sdk_version: 1.28.0 # Not needed for docker
8
- app_port: 7860
9
- app_file: app.py
10
  pinned: false
 
 
11
  ---
12
 
13
- # Sentiment Analysis App
14
 
15
- This is a simple Sentiment Analysis application built with [Streamlit](https://streamlit.io) and [Hugging Face Transformers](https://huggingface.co/docs/transformers).
16
 
17
- It uses the default `distilbert-base-uncased-finetuned-sst-2-english` model to classify text as **POSITIVE** or **NEGATIVE**.
 
 
1
  ---
2
  title: Sentiment Analysis App
3
+ emoji: 🚀
4
+ colorFrom: red
5
+ colorTo: red
6
  sdk: docker
7
+ app_port: 8501
8
+ tags:
9
+ - streamlit
10
  pinned: false
11
+ short_description: Sentiment Analysis App
12
+ license: mit
13
  ---
14
 
15
+ # Welcome to Streamlit!
16
 
17
+ Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
18
 
19
+ If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
20
+ forums](https://discuss.streamlit.io).
app.py DELETED
@@ -1,36 +0,0 @@
1
- import streamlit as st
2
- from transformers import pipeline
3
-
4
- # Set page title and header
5
- st.set_page_config(page_title="Sentiment Analysis App", page_icon="🤖")
6
- st.title("🤖 Sentiment Analysis with Hugging Face")
7
-
8
- st.markdown("""
9
- This app uses a pre-trained machine learning model from Hugging Face Transformers to analyze the sentiment of your text.
10
- """)
11
-
12
- # Load the pipeline (cached to avoid reloading on every interaction)
13
- @st.cache_resource
14
- def load_sentiment_pipeline():
15
- return pipeline("sentiment-analysis")
16
-
17
- classifier = load_sentiment_pipeline()
18
-
19
- # User input
20
- text_input = st.text_area("Enter some text here:", height=150, placeholder="I love building cool AI apps!")
21
-
22
- if st.button("Analyze Sentiment"):
23
- if text_input.strip():
24
- with st.spinner("Analyzing..."):
25
- result = classifier(text_input)[0]
26
- label = result['label']
27
- score = result['score']
28
-
29
- if label == 'POSITIVE':
30
- st.success(f"**Sentiment:** {label} 😊")
31
- else:
32
- st.error(f"**Sentiment:** {label} 😔")
33
-
34
- st.metric("Confidence Score", f"{score:.4f}")
35
- else:
36
- st.warning("Please enter some text to analyze.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- streamlit
2
- transformers
3
- torch
 
1
+ altair
2
+ pandas
3
+ streamlit
src/streamlit_app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import altair as alt
2
+ import numpy as np
3
+ import pandas as pd
4
+ import streamlit as st
5
+
6
+ """
7
+ # Welcome to Streamlit!
8
+
9
+ Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
+ If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
+ forums](https://discuss.streamlit.io).
12
+
13
+ In the meantime, below is an example of what you can do with just a few lines of code:
14
+ """
15
+
16
+ num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
+ num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
+
19
+ indices = np.linspace(0, 1, num_points)
20
+ theta = 2 * np.pi * num_turns * indices
21
+ radius = indices
22
+
23
+ x = radius * np.cos(theta)
24
+ y = radius * np.sin(theta)
25
+
26
+ df = pd.DataFrame({
27
+ "x": x,
28
+ "y": y,
29
+ "idx": indices,
30
+ "rand": np.random.randn(num_points),
31
+ })
32
+
33
+ st.altair_chart(alt.Chart(df, height=700, width=700)
34
+ .mark_point(filled=True)
35
+ .encode(
36
+ x=alt.X("x", axis=None),
37
+ y=alt.Y("y", axis=None),
38
+ color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
+ size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
+ ))