Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +16 -0
- app.py +42 -0
- requirements.txt +2 -0
Dockerfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9-slim
|
| 2 |
+
|
| 3 |
+
# Set the working directory inside the container
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
# Copy all files from the current directory to the container's working directory
|
| 7 |
+
COPY . .
|
| 8 |
+
|
| 9 |
+
# Install dependencies from the requirements file without using cache to reduce image size
|
| 10 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 11 |
+
|
| 12 |
+
# Define the command to start the application using Gunicorn with 4 worker processes
|
| 13 |
+
# - `-w 4`: Uses 4 worker processes for handling requests
|
| 14 |
+
# - `-b 0.0.0.0:7860`: Binds the server to port 7860 on all network interfaces
|
| 15 |
+
# - `app:app`: Runs the Flask app (assuming `app.py` contains the Flask instance named `app`)
|
| 16 |
+
CMD streamlit run app.py --server.port 7860
|
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
# Set the title of the Streamlit app
|
| 6 |
+
st.title("Superkart Forecast Revenue")
|
| 7 |
+
|
| 8 |
+
# Section for online prediction
|
| 9 |
+
st.subheader("Online Prediction")
|
| 10 |
+
|
| 11 |
+
# Collect user input for property features
|
| 12 |
+
product_weight = st.number_input("Product Weight", min_value=0)
|
| 13 |
+
product_allocated_area = st.number_input("Product Allocated Area", min_value=0)
|
| 14 |
+
product_mrp = st.number_input("Product MRP", min_value=0)
|
| 15 |
+
|
| 16 |
+
product_sugar_content = st.Product_Sugar_Content("Product Sugar Content", ["Low Sugar","Regular","No Sugar","reg"])
|
| 17 |
+
product_type = st.selectbox("Product Type", ["Fruits and Vegetables","Snack Foods","Frozen Foods","Dairy","Household","Baking Goods","Canned","Health and Hygiene","Meat","Soft Drinks","Breads","Hard Drinks","Others","Starchy Foods","Breakfast","Seafood"])
|
| 18 |
+
|
| 19 |
+
store_size = st.selectbox("Store Size", ["Small","Medium","Large"])
|
| 20 |
+
store_city = st.selectbox("Store Size", ["Tier 1","Tier 2","Tier 3"])
|
| 21 |
+
store_type = st.selectbox("Store Type", ["Food Mart","Departmental Store","Supermarket Type1","Supermarket Type2"])
|
| 22 |
+
|
| 23 |
+
# Convert user input into a DataFrame
|
| 24 |
+
input_data = pd.DataFrame([{
|
| 25 |
+
'product_weight': product_weight,
|
| 26 |
+
'product_allocated_area': product_allocated_area,
|
| 27 |
+
'product_mrp': product_mrp,
|
| 28 |
+
'product_sugar_content': product_sugar_content,
|
| 29 |
+
'product_type': product_type,
|
| 30 |
+
'store_size': store_size,
|
| 31 |
+
'city_type': store_city,
|
| 32 |
+
'store_type': store_type
|
| 33 |
+
}])
|
| 34 |
+
|
| 35 |
+
# Make prediction when the "Predict" button is clicked
|
| 36 |
+
if st.button("Predict"):
|
| 37 |
+
response = requests.post("https://shyamgoyal-ForecastRevenueBackend.hf.space/v1/revenue", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API
|
| 38 |
+
if response.status_code == 200:
|
| 39 |
+
prediction = response.json()['Forecasted Revenue (in dollars)']
|
| 40 |
+
st.success(f"Forecasted Revenue Price (in dollars): {prediction}")
|
| 41 |
+
else:
|
| 42 |
+
st.error("Error making prediction.")
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas==2.2.2
|
| 2 |
+
requests==2.28.1
|