AdrielAmoguis commited on
Commit
a3555b5
·
1 Parent(s): d4bc7b9

Added YOLO models

Browse files
Files changed (5) hide show
  1. M-Raw.pt +3 -0
  2. N-Raw.pt +3 -0
  3. S-Raw.pt +3 -0
  4. app.py +47 -0
  5. requirements.txt +4 -0
M-Raw.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d15f95658f7423ece0c2da12a9c4378348cf5e42deb081c24839c71d4e6dd1ca
3
+ size 52099424
N-Raw.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b35531393fe68c6f8d65bfc4d7ce909f2033f106a1ea3fd37c13db9d2086fa62
3
+ size 22557880
S-Raw.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:650137978f3688b85c43964630250da9ff479df21d52e91ba26e43334164ac3b
3
+ size 22557944
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from PIL import Image
3
+ import gradio as gr
4
+ from ultralytics import YOLO
5
+
6
+ # Load the YOLO model
7
+ m_raw_model = YOLO("M-Raw.pt")
8
+ n_raw_model = YOLO("N-Raw.pt")
9
+ s_raw_model = YOLO("S-Raw.pt")
10
+
11
+ def snap(image, model, conf):
12
+ # Convert the image to a numpy array
13
+ image = np.array(image)
14
+
15
+ # Run the selected model
16
+ results = None
17
+ if model == "M-Raw":
18
+ results = m_raw_model(image, conf=conf)
19
+ elif model == "N-Raw":
20
+ results = n_raw_model(image, conf=conf)
21
+ elif model == "S-Raw":
22
+ results = s_raw_model(image, conf=conf)
23
+
24
+ # Draw the bounding boxes
25
+ resulting_image = results.render()
26
+
27
+ # Convert the resulting image to a PIL image
28
+ resulting_image = Image.fromarray(resulting_image)
29
+
30
+ # Get the labels
31
+ labels = results.pandas().xyxy[0]["name"].values
32
+
33
+ # Sort the labels by their x-value
34
+ labels = labels[np.argsort(results.pandas().xyxy[0]["x"].values)]
35
+
36
+ return [resulting_image, labels]
37
+
38
+
39
+ demo = gr.Interface(
40
+ snap,
41
+ [gr.Image(source="webcam", tool=None, streaming=True), gr.inputs.Radio(["M-Raw", "N-Raw", "S-Raw"]), gr.inputs.Slider(0.0, 1.0, 0.5, 0.1, "Confidence")],
42
+ ["image", "labels"],
43
+ title="Baybayin Instance Detection"
44
+ )
45
+
46
+ if __name__ == "__main__":
47
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ numpy
2
+ Pillow
3
+ ultralytics
4
+ gradio