Spaces:
Runtime error
Runtime error
Commit
·
e23e47d
1
Parent(s):
6b03695
Added files
Browse files- Dockerfile +14 -0
- app.py +24 -0
- model.pkl +3 -0
- requirements.txt +6 -0
- templates/index.html +25 -0
- templates/predict.html +17 -0
Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
+
|
4 |
+
FROM python:3.9
|
5 |
+
|
6 |
+
WORKDIR /code
|
7 |
+
|
8 |
+
COPY ./requirements.txt /code/requirements.txt
|
9 |
+
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
11 |
+
|
12 |
+
COPY . .
|
13 |
+
|
14 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import flask
|
2 |
+
from flask import Flask, render_template, request, redirect, url_for
|
3 |
+
import pickle
|
4 |
+
|
5 |
+
app = Flask(__name__)
|
6 |
+
# loaded_model = joblib.load('model.pkl')
|
7 |
+
loaded_model = pickle.load(open('model.pkl', 'rb'))
|
8 |
+
@app.route("/")
|
9 |
+
def root():
|
10 |
+
return render_template("index.html")
|
11 |
+
@app.route("/predict", methods=['POST'])
|
12 |
+
def make_prediction():
|
13 |
+
|
14 |
+
if request.method == 'POST':
|
15 |
+
exp = request.form['exp']
|
16 |
+
X = [[float(exp)]]
|
17 |
+
[prediction] = loaded_model.predict(X)
|
18 |
+
salary = round(prediction, 2)
|
19 |
+
# msg = "Standard salary for provided experience of " + str(exp) + " years, would be: ₹ " + str(salary) + "/-- "
|
20 |
+
msg = "Standard salary for provided experience of " + str(exp) + " years, would be: Rp. " + str(salary)
|
21 |
+
|
22 |
+
return render_template("index.html", prediction_text= msg)
|
23 |
+
if __name__ == '__main__':
|
24 |
+
app.run( debug=True)
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b9123d8808c50fe91e2aeb83907ef24a5a0bf70f6b163591cd79991c35187605
|
3 |
+
size 419
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
joblib==0.13.2
|
2 |
+
Flask==1.0.3
|
3 |
+
numpy==1.17.2
|
4 |
+
pandas==0.25.1
|
5 |
+
scikit_learn==0.21.3
|
6 |
+
gunicorn==19.9.0
|
templates/index.html
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<title>Base ML model</title>
|
6 |
+
<style>
|
7 |
+
body {
|
8 |
+
background-color: #E6E6FA
|
9 |
+
}
|
10 |
+
</style>
|
11 |
+
</head>
|
12 |
+
<body>
|
13 |
+
<h1> Predict standard salary from candidate experience </h1>
|
14 |
+
<form action = {{ url_for('make_prediction')}} method = "post">
|
15 |
+
<p>Enter candidate experience (in yrs):</p>
|
16 |
+
<p><input type="float" name = "exp" pattern="[+-]?([0-9]*[.])?[0-9]+" oninvalid="setCustomValidity('Plz enter a valid experience value')"
|
17 |
+
onchange="try{setCustomValidity('')}catch(e){}" /></p>
|
18 |
+
<p><input type = "submit" value="predict"/> </p>
|
19 |
+
</form>
|
20 |
+
|
21 |
+
<br></br>
|
22 |
+
<h3>{{ prediction_text }} </h3>
|
23 |
+
|
24 |
+
</body>
|
25 |
+
</html>
|
templates/predict.html
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<title>Prediction</title>
|
6 |
+
<style>
|
7 |
+
body {
|
8 |
+
background-color: #E6E6FA
|
9 |
+
}
|
10 |
+
</style>
|
11 |
+
</head>
|
12 |
+
<body>
|
13 |
+
<h2> Standard salary for provided experience of {{ experience }} years would be :</h2>
|
14 |
+
<!-- <h1> ₹ {{ salary }} /-- </h1> -->
|
15 |
+
<h1> Rp. {{ salary }} /-- </h1>
|
16 |
+
</body>
|
17 |
+
</html>
|