Bhaskarsai4 commited on
Commit
48e86aa
1 Parent(s): 19224a5

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +38 -0
  2. best.pt +3 -0
  3. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cv2
3
+ import numpy as np
4
+ from collections import Counter
5
+ from ultralytics import YOLO
6
+
7
+ # Load YOLOv10 model
8
+ model_path = "best.pt"
9
+ model = YOLO(model_path)
10
+
11
+ # Define the predict function
12
+ def predict(image):
13
+ image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
14
+ result = model.predict(source=image_rgb, imgsz=640, conf=0.25)
15
+
16
+ annotated_img = result[0].plot()
17
+
18
+ detections = result[0].boxes.data
19
+ class_names = [model.names[int(cls)] for cls in detections[:, 5]]
20
+ count = Counter(class_names)
21
+
22
+ detection_str = ', '.join([f"{name}: {count}" for name, count in count.items()])
23
+ annotated_img = annotated_img[:, :, ::-1]
24
+
25
+ return annotated_img, detection_str
26
+
27
+ # Create Gradio interface
28
+ app = gr.Interface(
29
+ predict,
30
+ inputs=gr.Image(type="numpy", label="Upload an image"),
31
+ outputs=[gr.Image(type="numpy", label="Annotated Image"), gr.Textbox(label="Detection Count")],
32
+ title="Blood Cell Count using YOLO V10",
33
+ description="Upload an image,then YOLO V10 model will detect and annotate blood cells."
34
+ )
35
+
36
+ # Launch the app
37
+ if __name__ == "__main__":
38
+ app.launch(share=True, server_port=8080, debug=True)
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f98dfcf46648763e3c8f45ca85e04e45cf70d010fc567712499737c611c58f88
3
+ size 5753203
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ gradio
2
+ opencv-python
3
+ roboflow
4
+ torch
5
+ albumentations
6
+ ultralytics