1st upload for app.py,requirements.txt and model3.joblib
Browse files- app.py +52 -0
- model-v3.joblib +3 -0
- requirements.txt +7 -0
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import joblib
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
import pandas as pd
|
6 |
+
|
7 |
+
|
8 |
+
price_predictor=joblib.load("model-v3.joblib")
|
9 |
+
|
10 |
+
carat_input=gr.Number(label="Carat")
|
11 |
+
shape_input=gr.Dropdown(['Round', 'Emerald', 'Marquise', 'Princess', 'Pear', 'Heart',
|
12 |
+
'Oval', 'Cushion', 'Asscher', 'Radiant'],label='Shape')
|
13 |
+
|
14 |
+
cut_input=gr.Dropdown(['Very Good', 'Ideal', 'Super Ideal', 'Good', 'Fair'],label='Cut')
|
15 |
+
|
16 |
+
color_input=gr.Dropdown(['J', 'I', 'E', 'F', 'G', 'H', 'D'],label='Color')
|
17 |
+
|
18 |
+
clarity_input=gr.Dropdown(['SI2', 'SI1', 'VS2', 'VVS1', 'VS1', 'VVS2', 'IF', 'FL'],label='Clarity')
|
19 |
+
|
20 |
+
report_input=gr.Dropdown(['GIA', 'HRD', 'IGI', 'GCAL'],label='Report')
|
21 |
+
|
22 |
+
type_input=gr.Dropdown(['natural', 'lab'],label='Type')
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
model_output=gr.Label(label="Predicted Price (USD)")
|
28 |
+
|
29 |
+
def predict_price(carat,shape,cut,color,clarity,report,type):
|
30 |
+
sample={'caret':carat,
|
31 |
+
'shape':shape,
|
32 |
+
'cut':cut,
|
33 |
+
'color':color,
|
34 |
+
'clarity':clarity,
|
35 |
+
'report':report,
|
36 |
+
'type':type,
|
37 |
+
}
|
38 |
+
data_point=pd.DataFrame([sample])
|
39 |
+
prediction=price_predictor.predict(data_point).tolist()
|
40 |
+
return prediction[0]
|
41 |
+
|
42 |
+
demo=gr.Interface(
|
43 |
+
fn=predict_price,
|
44 |
+
inputs=[carat_input,shape_input,cut_input,color_input,clarity_input,report_input,type_input],
|
45 |
+
outputs=model_output,
|
46 |
+
theme=gr.themes.Soft(),
|
47 |
+
title="Predictor of Diamond Valuations",
|
48 |
+
description="This application enables you to estimate the value of diamonds based on their characteristics",
|
49 |
+
#allow_flagging="auto",
|
50 |
+
#flagging_callback=hf_writer,
|
51 |
+
concurrency_limit=8
|
52 |
+
)
|
model-v3.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2aaced60665688b76a1a99009f72c30fe47a413069eb7a495ebe95c6661b0f08
|
3 |
+
size 5323520
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==4.29.0
|
2 |
+
pandas>=1.4.0,<1.6.0
|
3 |
+
scikit-learn==1.2.2
|
4 |
+
joblib==1.2.0
|
5 |
+
|
6 |
+
|
7 |
+
|