Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
| 1 |
from ultralytics import YOLO
|
| 2 |
import numpy as np
|
| 3 |
-
import matplotlib.pyplot as plt
|
| 4 |
import cv2
|
| 5 |
import gradio as gr
|
| 6 |
import pickle
|
| 7 |
-
|
| 8 |
# function which is returning the number of object detected
|
| 9 |
def number_object_detected(image):
|
| 10 |
|
|
@@ -20,12 +18,9 @@ def number_object_detected(image):
|
|
| 20 |
for e , count in zip(unique_elements,counts):
|
| 21 |
a = dic[e]
|
| 22 |
class_count[a] = count
|
| 23 |
-
|
| 24 |
-
|
| 25 |
return (class_count,results )
|
| 26 |
|
| 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,6 +54,7 @@ def car_detection_and_Cropping(image_path):
|
|
| 59 |
class_c ,result= number_object_detected(image_path)
|
| 60 |
return class_c ,result
|
| 61 |
|
|
|
|
| 62 |
severity_points = {
|
| 63 |
'scratch': 1,
|
| 64 |
'dent': 2,
|
|
@@ -100,6 +96,8 @@ def estimate_condition(detections):
|
|
| 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 |
|
|
@@ -110,7 +108,7 @@ def process_data(files,car_brand, car_name, model_year, mileage, city_registered
|
|
| 110 |
file_names = [f[0] for f in files]
|
| 111 |
image_r = []
|
| 112 |
|
| 113 |
-
|
| 114 |
damage_dic = {}
|
| 115 |
|
| 116 |
for f in file_names:
|
|
@@ -135,6 +133,7 @@ def process_data(files,car_brand, car_name, model_year, mileage, city_registered
|
|
| 135 |
|
| 136 |
return (condition , str(price[0])+'lacs' , image_r)
|
| 137 |
|
|
|
|
| 138 |
years_list = list(range(2024, 1899, -1))
|
| 139 |
gr.Interface(fn = process_data,
|
| 140 |
inputs=[gr.Gallery(label="Upload Files", type="filepath"),
|
|
|
|
| 1 |
from ultralytics import YOLO
|
| 2 |
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 |
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 |
class_c ,result= number_object_detected(image_path)
|
| 55 |
return class_c ,result
|
| 56 |
|
| 57 |
+
|
| 58 |
severity_points = {
|
| 59 |
'scratch': 1,
|
| 60 |
'dent': 2,
|
|
|
|
| 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 |
|
|
|
|
| 108 |
file_names = [f[0] for f in files]
|
| 109 |
image_r = []
|
| 110 |
|
| 111 |
+
|
| 112 |
damage_dic = {}
|
| 113 |
|
| 114 |
for f in file_names:
|
|
|
|
| 133 |
|
| 134 |
return (condition , str(price[0])+'lacs' , image_r)
|
| 135 |
|
| 136 |
+
|
| 137 |
years_list = list(range(2024, 1899, -1))
|
| 138 |
gr.Interface(fn = process_data,
|
| 139 |
inputs=[gr.Gallery(label="Upload Files", type="filepath"),
|