Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +15 -12
- app.py +64 -0
- requirements.txt +8 -3
Dockerfile
CHANGED
|
@@ -1,20 +1,23 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
curl \
|
| 8 |
-
git \
|
| 9 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
RUN
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
| 1 |
+
#Use a minimal base image with python 3.9 installed
|
| 2 |
+
FROM python:3.9
|
| 3 |
|
| 4 |
+
#set the working directory inside the container to /app
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
#copy all the files from the current directory on the host to the container's /app directory
|
| 8 |
+
COPY . .
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
#Install python dependencies listed in requirements.text
|
| 11 |
+
RUN pip install -r requirements.txt
|
| 12 |
|
| 13 |
+
RUN useradd -m -u 1000 user
|
| 14 |
+
USER user
|
| 15 |
+
ENV HOME=/home/user \
|
| 16 |
+
PATH=/home/user/.local/bin:$PATH
|
| 17 |
|
| 18 |
+
WORKDIR $HOME/app
|
| 19 |
|
| 20 |
+
COPY --chown=user . $HOME/app
|
| 21 |
|
| 22 |
+
#Define the command to run the Streamlit app on port "8501" and make itaccessible externally
|
| 23 |
+
CMD ["streamlit","run","app.py","--server.port=8501", "--server.address=0.0.0.0","--server.enableXsrfProtection-False" "]
|
app.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
import json
|
| 4 |
+
import pandas as pd
|
| 5 |
+
from huggingface_hub import hf_hub_download # Corrected import statement
|
| 6 |
+
import joblib # Corrected typo
|
| 7 |
+
|
| 8 |
+
#Download and load the model
|
| 9 |
+
model_path = hf_hub_download(repo_id="grkavi0912/Tpro", filename="best_tour_model.joblib", repo_type="model") # Added repo_type
|
| 10 |
+
model = joblib.load(model_path)
|
| 11 |
+
|
| 12 |
+
#Streamlit UI for Tourism package prediction
|
| 13 |
+
st.title("Tourism Package Prediction")
|
| 14 |
+
st.write("Enter the details to predict the package price")
|
| 15 |
+
|
| 16 |
+
#User input
|
| 17 |
+
Age = st.number_input("Age",min_value=18,max_value=100)
|
| 18 |
+
Type_of_contact = st.selectbox("Type of Contact",["Direct","Call"])
|
| 19 |
+
City_Tier = st.selectbox("City Tier",[1,2,3])
|
| 20 |
+
Duration_of_Pitch = st.number_input("Duration of Pitch",min_value=1,max_value=365)
|
| 21 |
+
Occupation = st.selectbox("Occupation",["Self-employed","Salaried","Business"])
|
| 22 |
+
Gender = st.selectbox("Gender",["Male","Female"])
|
| 23 |
+
Number_of_Person_Visiting= st.number_input("Number of Person Traveling",min_value=1,max_value=10)
|
| 24 |
+
Number_of_Followups= st.number_input("Number of Followups",min_value=0,max_value=10)
|
| 25 |
+
Product_Pitched= st.selectbox("Product Pitched",["Basic","Standard","Premium"])
|
| 26 |
+
Preferred_Property_Star= st.number_input("Preferred Property Star",min_value=1,max_value=5)
|
| 27 |
+
Marital_Status= st.selectbox("Marital Status",["Married","Divorced","Single"])
|
| 28 |
+
Number_of_Trips= st.number_input("Number of Trips",min_value=1,max_value=10)
|
| 29 |
+
Passport= st.selectbox("Passport",["Yes","No"])
|
| 30 |
+
Pitch_Satisfaction_Score= st.number_input("Pitch Satisfaction Score",min_value=1,max_value=5)
|
| 31 |
+
Own_Car= st.selectbox("Own Car",["Yes","No"])
|
| 32 |
+
Number_of_Children= st.number_input("Number of Children",min_value=0,max_value=10)
|
| 33 |
+
Designation= st.selectbox("Designation",["Executive","Manager","Senior Manager","Associate","Director"])
|
| 34 |
+
Monthly_Income= st.number_input("Monthly Income",min_value=0,max_value=100000)
|
| 35 |
+
|
| 36 |
+
#Assemble input into DataFrame
|
| 37 |
+
input_data = pd.DataFrame({
|
| 38 |
+
"Age": [Age],
|
| 39 |
+
"TypeofContact": [Type_of_contact], # Corrected variable name
|
| 40 |
+
"CityTier": [City_Tier], # Corrected variable name
|
| 41 |
+
"DurationOfPitch": [Duration_of_Pitch], # Corrected variable name
|
| 42 |
+
"Occupation": [Occupation],
|
| 43 |
+
"Gender": [Gender],
|
| 44 |
+
"NumberOfPersonVisiting": [Number_of_Person_Visiting], # Corrected variable name
|
| 45 |
+
"NumberOfFollowups": [Number_of_Followups], # Corrected variable name
|
| 46 |
+
"ProductPitched": [Product_Pitched], # Corrected variable name
|
| 47 |
+
"PreferredPropertyStar": [Preferred_Property_Star], # Corrected variable name
|
| 48 |
+
"MaritalStatus": [Marital_Status], # Corrected variable name
|
| 49 |
+
"NumberOfTrips": [Number_of_Trips], # Corrected variable name
|
| 50 |
+
"Passport": [1 if Passport == "Yes" else 0], # Converted to numerical
|
| 51 |
+
"PitchSatisfactionScore": [Pitch_Satisfaction_Score], # Corrected variable name
|
| 52 |
+
"OwnCar": [1 if Own_Car == "Yes" else 0], # Converted to numerical
|
| 53 |
+
"NumberOfChildrenVisiting": [Number_of_Children], # Corrected variable name
|
| 54 |
+
"Designation": [Designation],
|
| 55 |
+
"MonthlyIncome": [Monthly_Income]
|
| 56 |
+
|
| 57 |
+
})
|
| 58 |
+
|
| 59 |
+
if st.button("Predict"):
|
| 60 |
+
#Make prediction
|
| 61 |
+
prediction = model.predict(input_data)[0]
|
| 62 |
+
result = "Tourism package predicted as " + str(prediction)
|
| 63 |
+
st.subheader("Predicted Result:")
|
| 64 |
+
st.success(f"The model predicts: **{result}**")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,8 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
streamlit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas==2.2.as_integer_ratio
|
| 2 |
+
huggingface_hub==0.32.6
|
| 3 |
+
streamlit==1.43.2
|
| 4 |
+
joblib==1.5.1
|
| 5 |
+
scikit-learn==1.6.0
|
| 6 |
+
xgboost==2.1.4
|
| 7 |
+
mlflow==3.0.1
|
| 8 |
+
|