sahilsingla commited on
Commit
5333310
·
verified ·
1 Parent(s): 5e21d10

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +1 -1
  2. app.py +17 -0
  3. requirements.txt +1 -0
  4. test_app.py +38 -0
Dockerfile CHANGED
@@ -17,4 +17,4 @@ EXPOSE 8501
17
 
18
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
19
 
20
- ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
17
 
18
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
19
 
20
+ ENTRYPOINT ["streamlit", "run", "test_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
app.py CHANGED
@@ -105,3 +105,20 @@ if submitted:
105
  st.error(f"Error contacting the API: {e}")
106
  except ValueError:
107
  st.error("Invalid response format from API")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  st.error(f"Error contacting the API: {e}")
106
  except ValueError:
107
  st.error("Invalid response format from API")
108
+
109
+ # Section for batch prediction
110
+ st.subheader("Batch Prediction")
111
+
112
+ # Allow users to upload a CSV file for batch prediction
113
+ uploaded_file = st.file_uploader("Upload CSV file for batch prediction", type=["csv"])
114
+
115
+ # Make batch prediction when the "Predict Batch" button is clicked
116
+ if uploaded_file is not None:
117
+ if st.button("Predict Batch"):
118
+ response = requests.post("https://sahilsingla-SuperKartPredictionBackend.hf.space/v1/sales", files={"file": uploaded_file}) # Send file to Flask API
119
+ if response.status_code == 200:
120
+ predictions = response.json()
121
+ st.success("Batch predictions completed!")
122
+ st.write(predictions) # Display the predictions
123
+ else:
124
+ st.error("Error making batch prediction.")
requirements.txt CHANGED
@@ -1,3 +1,4 @@
 
1
  pandas==2.2.2
2
  requests==2.28.1
3
  streamlit==1.43.2
 
1
+ altair
2
  pandas==2.2.2
3
  requests==2.28.1
4
  streamlit==1.43.2
test_app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 test Streamlit!
8
+ Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
9
+ If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
10
+ forums](https://discuss.streamlit.io).
11
+ In the meantime, below is an example of what you can do with just a few lines of code:
12
+ """
13
+
14
+ num_points = st.slider("Number of points in spiral", 1, 20000, 1100)
15
+ num_turns = st.slider("Number of turns in spiral", 1, 500, 31)
16
+
17
+ indices = np.linspace(0, 1, num_points)
18
+ theta = 2 * np.pi * num_turns * indices
19
+ radius = indices
20
+
21
+ x = radius * np.cos(theta)
22
+ y = radius * np.sin(theta)
23
+
24
+ df = pd.DataFrame({
25
+ "x": x,
26
+ "y": y,
27
+ "idx": indices,
28
+ "rand": np.random.randn(num_points),
29
+ })
30
+
31
+ st.altair_chart(alt.Chart(df, height=700, width=700)
32
+ .mark_point(filled=True)
33
+ .encode(
34
+ x=alt.X("x", axis=None),
35
+ y=alt.Y("y", axis=None),
36
+ color=alt.Color("idx", legend=None, scale=alt.Scale()),
37
+ size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
38
+ ))