aryan365 commited on
Commit
3dfe98c
·
verified ·
1 Parent(s): a2b026f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -25,6 +25,7 @@ vegetables = [
25
  model = YOLO('fresh_model.pt')
26
  # Load the YOLO model
27
  yolo_model = YOLO('another_model.pt') # Adjust the path as needed
 
28
 
29
  @app.route('/')
30
  def index():
@@ -54,7 +55,7 @@ def predict():
54
  # Use model's class names dynamically
55
  vegetable_name = model.names[class_index] # Get the name directly from the model
56
  detected_vegetables.append(vegetable_name)
57
- detected_classes=str(detected_vegetables[0])
58
 
59
  return jsonify({'predictions': detected_classes})
60
  except Exception as e:
@@ -93,7 +94,7 @@ def detect():
93
 
94
 
95
 
96
- model = YOLO('model_2.pt') # Replace with your model's path
97
 
98
  @app.route('/ocr', methods=['POST'])
99
  def ocr():
@@ -105,7 +106,7 @@ def ocr():
105
  image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
106
 
107
  # Perform text detection using YOLO
108
- results = model(image)
109
  detections = results[0].boxes
110
  high_conf_detections = [box for box in detections if box.conf > 0.55]
111
 
 
25
  model = YOLO('fresh_model.pt')
26
  # Load the YOLO model
27
  yolo_model = YOLO('another_model.pt') # Adjust the path as needed
28
+ CONFIDENCE_THRESHOLD=0.6
29
 
30
  @app.route('/')
31
  def index():
 
55
  # Use model's class names dynamically
56
  vegetable_name = model.names[class_index] # Get the name directly from the model
57
  detected_vegetables.append(vegetable_name)
58
+ detected_classes=detected_vegetables
59
 
60
  return jsonify({'predictions': detected_classes})
61
  except Exception as e:
 
94
 
95
 
96
 
97
+ modeltext = YOLO('model_2.pt') # Replace with your model's path
98
 
99
  @app.route('/ocr', methods=['POST'])
100
  def ocr():
 
106
  image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
107
 
108
  # Perform text detection using YOLO
109
+ results = modeltext(image)
110
  detections = results[0].boxes
111
  high_conf_detections = [box for box in detections if box.conf > 0.55]
112