saad1BM commited on
Commit
9bb292d
·
verified ·
1 Parent(s): b3a8e63

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +31 -0
  2. best.pt +3 -0
  3. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ultralytics import YOLO
3
+ from PIL import Image
4
+
5
+ # Model load karein (ensure karein best.pt upload ho chuki hai)
6
+ model = YOLO("best.pt")
7
+
8
+ def predict_image(img):
9
+ # Model prediction
10
+ results = model(img)
11
+
12
+ # Annotated image hasil karein (boxes ke saath)
13
+ # results[0].plot() humein numpy array deta hai jis par boxes bane hote hain
14
+ res_plotted = results[0].plot()
15
+
16
+ # RGB mein convert karein taake Gradio sahi dikhaye
17
+ output_img = Image.fromarray(res_plotted[:, :, ::-1])
18
+
19
+ return output_img
20
+
21
+ # Gradio interface setup
22
+ demo = gr.Interface(
23
+ fn=predict_image,
24
+ inputs=gr.Image(type="pil"),
25
+ outputs=gr.Image(type="pil"),
26
+ title="Face Mask Detection (YOLOv8)",
27
+ description="Apni photo upload karein. Model 'with_mask', 'without_mask', ya 'incorrect' detect karega."
28
+ )
29
+
30
+ if __name__ == "__main__":
31
+ demo.launch()
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09289b1ccee1f7abd8e716976130685ef9ec8f2628a3518e364c0e3646616208
3
+ size 6190122
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ultralytics
2
+ gradio
3
+ opencv-python-headless