File size: 1,778 Bytes
835d453
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import gradio as gr
import pandas as pd
import numpy as np
import sklearn
import pickle
model = pickle.load(open('random_forest_regression_model.pkl', 'rb'))

import gradio as gr
def car(Year,owners,sp,fuel,distance,tyype,trans):
  if fuel =="PETROL":
    p,d=1,0
  if fuel =="DIESEL":
    p,d=0,1
  if fuel =="CNG":
    p,d=0,0
  year = 2022-Year
  if tyype=="Individual":
    st=1
  else:
    st=0
  if trans=="Manual":
    t=1
  else:
    t=0
  error = "ใ€ ๐—˜๐—ฟ๐—ฟ๐—ผ๐—ฟ ๐Ÿฐ๐Ÿฌ๐Ÿฐ : ๐—ฉ๐—ฎ๐—น๐˜‚๐—ฒ ๐— ๐—ถ๐˜€๐˜€๐—ถ๐—ป๐—ด ใ€‘"
  prediction=model.predict([[sp,distance,owners,year,d,p,st,t]])
  output=round(prediction[0],2)
  ou= str(output)
  if Year==0 or distance==0 or sp==0:
    return error
  else:
    return "The Price of Will be  โ‚น" + ou  + "L !"
# face = gr.Interface(fn=start, inputs=["text", "checkbox","N", gr.inputs.Slider(0, 100),gr.inputs.Radio(["add", "subtract", "multiply"])], outputs=["text", "number"])
# face.launch()

# ---------------------------------INPUTS :------------------------------

# in1=gr.inputs.Textbox(placeholder="En",label="MO")
in2=gr.inputs.Number(label='Which Model (Year)ใ€*ใ€‘',default=0)
in3= gr.inputs.Slider(0, 10,1,label="No. of Previous Owners eg.")
in4=gr.inputs.Number(label='Kilometeres Drivedใ€*ใ€‘',default=0)
in5= gr.inputs.Radio(["PETROL", "DIESEL", "CNG"])
in6=gr.inputs.Dropdown(["Individual", "Dealer"],label="You Are")
in7=gr.inputs.Dropdown(["Automatic", "Manual"],label="Transmission Type")
in8=gr.inputs.Number(label='Showroom Price โ‚น(in LAKHS)ใ€*ใ€‘',default=0)

interface = gr.Interface(fn=car,
                         inputs=[in2,in3,in8,in5,in4,in6,in7],
                         outputs=["text"],title="Car calculator"
                         )
interface.launch(inline=False)