azizmeer40 commited on
Commit
13335b4
·
verified ·
1 Parent(s): b1f8699

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -94,19 +94,20 @@ def process_frame():
94
  nparr = np.frombuffer(img_data, np.uint8)
95
  frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
96
 
97
- # 1. YOLO Detection
98
- detections = detect_objects(frame, confidence=0.4)
99
 
100
- # 2. SMART SORTING: Sabse bari cheez ko pehle rakhein
101
- # Logic: Jis box ka area (w * h) bara hoga, wo cheez kareeb hogi
102
  if detections:
 
103
  detections = sorted(detections, key=lambda x: x['w'] * x['h'], reverse=True)
 
 
104
 
105
  return jsonify({"detections": detections})
106
 
107
  except Exception as e:
108
- print(f"Error: {e}")
109
- return jsonify({"error": str(e)}), 400
110
 
111
  @app.route('/logout')
112
  def logout():
 
94
  nparr = np.frombuffer(img_data, np.uint8)
95
  frame = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
96
 
97
+ # Confidence thoda kam (0.35) taake cheezein miss na hon
98
+ detections = detect_objects(frame, confidence=0.35)
99
 
100
+ # AREA-BASED SORTING (Zaroori hai VI ke liye)
 
101
  if detections:
102
+ # Sabse bari cheez list mein pehle aayegi
103
  detections = sorted(detections, key=lambda x: x['w'] * x['h'], reverse=True)
104
+ # Sirf top 3 cheezein bhejien taake frontend fast rahe
105
+ detections = detections[:3]
106
 
107
  return jsonify({"detections": detections})
108
 
109
  except Exception as e:
110
+ return jsonify({"error": "Processing error"}), 400
 
111
 
112
  @app.route('/logout')
113
  def logout():