atticus-carter
commited on
Commit
•
00c3fc4
1
Parent(s):
3481f66
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,36 @@
|
|
1 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
# Create a slider and display the squared value
|
4 |
-
x = st.slider('Select a value', 0, 100)
|
5 |
-
st.write(x, 'squared is', x * x)
|
|
|
1 |
+
import glob
|
2 |
+
import gradio as gr
|
3 |
+
from ultralytics import YOLO
|
4 |
+
|
5 |
+
model_path = "best.pt"
|
6 |
+
model = YOLO(model_path)
|
7 |
+
|
8 |
+
|
9 |
+
PREDICT_KWARGS = {
|
10 |
+
"conf": 0.15,
|
11 |
+
}
|
12 |
+
|
13 |
+
|
14 |
+
def run(image_path):
|
15 |
+
results = model.predict(image_path, **PREDICT_KWARGS)
|
16 |
+
return results[0].plot()[:, :, ::-1] # reverse channels for gradio
|
17 |
+
|
18 |
+
|
19 |
+
title = "OOI RCA Digital Still Camera Benthic Megafauna Detector"
|
20 |
+
description = (
|
21 |
+
""
|
22 |
+
)
|
23 |
+
|
24 |
+
examples = glob.glob("images/*.png")
|
25 |
+
|
26 |
+
interface = gr.Interface(
|
27 |
+
run,
|
28 |
+
inputs=[gr.components.Image(type="filepath")],
|
29 |
+
outputs=gr.components.Image(type="numpy"),
|
30 |
+
title=title,
|
31 |
+
description=description,
|
32 |
+
examples=examples,
|
33 |
+
)
|
34 |
+
|
35 |
+
interface.queue().launch()
|
36 |
|
|
|
|
|
|