Spaces:
Build error
Build error
Upload 4 files
Browse files
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
|
data.yaml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
train: ../train/images
|
| 2 |
+
val: ../valid/images
|
| 3 |
+
test: ../test/images
|
| 4 |
+
|
| 5 |
+
nc: 3
|
| 6 |
+
names: ['mask_weared_incorrect', 'with_mask', 'without_mask']
|
| 7 |
+
|
| 8 |
+
roboflow:
|
| 9 |
+
workspace: saad-n
|
| 10 |
+
project: face-mask-y1vsd-mq8qr
|
| 11 |
+
version: 1
|
| 12 |
+
license: CC BY 4.0
|
| 13 |
+
url: https://universe.roboflow.com/saad-n/face-mask-y1vsd-mq8qr/dataset/1
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ultralytics
|
| 2 |
+
gradio
|
| 3 |
+
opencv-python
|
| 4 |
+
PIL
|