Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -41,3 +41,37 @@ input_data = pd.DataFrame([{
|
|
| 41 |
'Store_Type': Store_Type
|
| 42 |
}])
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
'Store_Type': Store_Type
|
| 42 |
}])
|
| 43 |
|
| 44 |
+
# Make prediction when the "Predict" button is clicked
|
| 45 |
+
if st.button("Predict Sales"):
|
| 46 |
+
response = requests.post(
|
| 47 |
+
"https://Anusha3-Superkart-Backend-Docker-space.hf.space/v1/sales",
|
| 48 |
+
json=input_data.to_dict(orient='records')[0]
|
| 49 |
+
) # Send data to backend API
|
| 50 |
+
|
| 51 |
+
if response.status_code == 200:
|
| 52 |
+
prediction = response.json()['Predicted Sales']
|
| 53 |
+
st.success(f"Predicted Sales: {prediction}")
|
| 54 |
+
else:
|
| 55 |
+
st.error("Error making prediction. Please check the backend logs.")
|
| 56 |
+
|
| 57 |
+
# Section for batch prediction
|
| 58 |
+
st.subheader("Batch Prediction")
|
| 59 |
+
|
| 60 |
+
# Allow users to upload a CSV file for batch prediction
|
| 61 |
+
uploaded_file = st.file_uploader("Upload CSV file for batch prediction", type=["csv"])
|
| 62 |
+
|
| 63 |
+
# Make batch prediction when the "Predict Batch" button is clicked
|
| 64 |
+
if uploaded_file is not None:
|
| 65 |
+
if st.button("Predict Batch Sales"):
|
| 66 |
+
response = requests.post(
|
| 67 |
+
"https://Anusha3-Superkart-Backend-Docker-space.hf.space/v1/salesbatch", files={"file": uploaded_file} ) # Send file to backend API
|
| 68 |
+
|
| 69 |
+
if response.status_code == 200:
|
| 70 |
+
predictions = response.json()
|
| 71 |
+
st.success(" Batch predictions completed!")
|
| 72 |
+
st.write(predictions) # Display the predictions
|
| 73 |
+
else:
|
| 74 |
+
st.error("Error making batch prediction.")
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
|