Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import numpy as np
|
|
3 |
import cv2
|
4 |
import gradio as gr
|
5 |
import pickle
|
|
|
6 |
# function which is returning the number of object detected
|
7 |
def number_object_detected(image):
|
8 |
|
@@ -18,9 +19,13 @@ def number_object_detected(image):
|
|
18 |
for e , count in zip(unique_elements,counts):
|
19 |
a = dic[e]
|
20 |
class_count[a] = count
|
21 |
-
|
|
|
|
|
|
|
22 |
return (class_count,results )
|
23 |
|
|
|
24 |
def car_detection_and_Cropping(image_path):
|
25 |
simple_yolo = YOLO('yolov8m.pt')
|
26 |
r = simple_yolo(image_path,verbose = False)
|
@@ -54,7 +59,6 @@ def car_detection_and_Cropping(image_path):
|
|
54 |
class_c ,result= number_object_detected(image_path)
|
55 |
return class_c ,result
|
56 |
|
57 |
-
|
58 |
severity_points = {
|
59 |
'scratch': 1,
|
60 |
'dent': 2,
|
@@ -81,7 +85,7 @@ def estimate_condition(detections):
|
|
81 |
print("normalized Score",normalized_score)
|
82 |
# Assign condition rating
|
83 |
if normalized_score <= 4: # If score is low, condition is Excellent
|
84 |
-
|
85 |
return "Excellent"
|
86 |
elif (normalized_score >4 and normalized_score <=7): # If score is moderately low, condition is Good
|
87 |
|
@@ -96,12 +100,9 @@ def estimate_condition(detections):
|
|
96 |
|
97 |
return "Very Poor"
|
98 |
|
99 |
-
|
100 |
-
|
101 |
with open('Price_prediction_decision_tree.pkl', 'rb') as file:
|
102 |
loaded_pipe_lr = pickle.load(file)
|
103 |
|
104 |
-
|
105 |
## loading the model
|
106 |
def process_data(files,car_brand, car_name, model_year, mileage, city_registered, color, engine_c, trans, fuel_type, Cate):
|
107 |
|
@@ -131,8 +132,9 @@ def process_data(files,car_brand, car_name, model_year, mileage, city_registered
|
|
131 |
if price[0] >= 100:
|
132 |
price[0] = price[0]/100
|
133 |
|
134 |
-
return (
|
135 |
|
|
|
136 |
|
137 |
years_list = list(range(2024, 1899, -1))
|
138 |
gr.Interface(fn = process_data,
|
@@ -148,5 +150,4 @@ gr.Interface(fn = process_data,
|
|
148 |
# gr.Radio(["imported", "local"], label="Assembly Type"),
|
149 |
gr.Radio(["hybrid", "petrol",'diesel'], label="Fuel Type"),
|
150 |
gr.Radio(["hatchback", "sedan",'suv','croosover','van'], label="Category")],
|
151 |
-
outputs=[gr.Textbox(label="Predicted Price"),gr.Gallery(label='output',type='pil')]).launch()
|
152 |
-
|
|
|
3 |
import cv2
|
4 |
import gradio as gr
|
5 |
import pickle
|
6 |
+
|
7 |
# function which is returning the number of object detected
|
8 |
def number_object_detected(image):
|
9 |
|
|
|
19 |
for e , count in zip(unique_elements,counts):
|
20 |
a = dic[e]
|
21 |
class_count[a] = count
|
22 |
+
#print(class_count)
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
return (class_count,results )
|
27 |
|
28 |
+
|
29 |
def car_detection_and_Cropping(image_path):
|
30 |
simple_yolo = YOLO('yolov8m.pt')
|
31 |
r = simple_yolo(image_path,verbose = False)
|
|
|
59 |
class_c ,result= number_object_detected(image_path)
|
60 |
return class_c ,result
|
61 |
|
|
|
62 |
severity_points = {
|
63 |
'scratch': 1,
|
64 |
'dent': 2,
|
|
|
85 |
print("normalized Score",normalized_score)
|
86 |
# Assign condition rating
|
87 |
if normalized_score <= 4: # If score is low, condition is Excellent
|
88 |
+
|
89 |
return "Excellent"
|
90 |
elif (normalized_score >4 and normalized_score <=7): # If score is moderately low, condition is Good
|
91 |
|
|
|
100 |
|
101 |
return "Very Poor"
|
102 |
|
|
|
|
|
103 |
with open('Price_prediction_decision_tree.pkl', 'rb') as file:
|
104 |
loaded_pipe_lr = pickle.load(file)
|
105 |
|
|
|
106 |
## loading the model
|
107 |
def process_data(files,car_brand, car_name, model_year, mileage, city_registered, color, engine_c, trans, fuel_type, Cate):
|
108 |
|
|
|
132 |
if price[0] >= 100:
|
133 |
price[0] = price[0]/100
|
134 |
|
135 |
+
return ( str(price[0])+'lacs' , image_r)
|
136 |
|
137 |
+
|
138 |
|
139 |
years_list = list(range(2024, 1899, -1))
|
140 |
gr.Interface(fn = process_data,
|
|
|
150 |
# gr.Radio(["imported", "local"], label="Assembly Type"),
|
151 |
gr.Radio(["hybrid", "petrol",'diesel'], label="Fuel Type"),
|
152 |
gr.Radio(["hatchback", "sedan",'suv','croosover','van'], label="Category")],
|
153 |
+
outputs=[gr.Textbox(label="Predicted Price"),gr.Gallery(label='output',type='pil')]).launch()
|
|