saad1BM commited on
Commit
85228df
·
verified ·
1 Parent(s): 032655a

Upload 3 files

Browse files
Files changed (3) hide show
  1. best.pt +3 -0
  2. mask_test.py +40 -0
  3. requirements.txt +3 -0
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09289b1ccee1f7abd8e716976130685ef9ec8f2628a3518e364c0e3646616208
3
+ size 6190122
mask_test.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mask_test.py
2
+ import cv2
3
+ from ultralytics import YOLO
4
+
5
+ # 1. Model Load Karein
6
+ # Training ke baad aapki best file yahan hoti hai: runs/detect/train/weights/best.pt
7
+ # Agar aapki training 'train6' thi, toh path hoga: 'runs/detect/train6/weights/best.pt'
8
+ model_path = r'best.pt'
9
+
10
+ try:
11
+ model = YOLO(model_path)
12
+ print("Model successfully load ho gaya!")
13
+ except:
14
+ print("Error: 'best.pt' nahi mili. Path check karein.")
15
+ exit()
16
+
17
+ # 2. Camera On Karein
18
+ cap = cv2.pycam = cv2.VideoCapture(0)
19
+
20
+ print("Camera start ho raha hai... Band karne ke liye 'q' dabayein.")
21
+
22
+ while cap.isOpened():
23
+ success, frame = cap.read()
24
+ if not success:
25
+ break
26
+
27
+ # 3. Mask Detection (Model Prediction)
28
+ results = model(frame, conf=0.5) # 0.5 matlab 50% sure hoga toh dikhayega
29
+
30
+ # 4. Results dikhayein
31
+ annotated_frame = results[0].plot()
32
+
33
+ cv2.imshow("Face Mask Detection Test", annotated_frame)
34
+
35
+ # 'q' dabane se window band ho jayegi
36
+ if cv2.waitKey(1) & 0xFF == ord('q'):
37
+ break
38
+
39
+ cap.release()
40
+ cv2.destroyAllWindows()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ultralytics
2
+ gradio
3
+ opencv-python-headless