Spaces:
Runtime error
Runtime error
Léo Andéol
commited on
Commit
·
2fc4677
1
Parent(s):
5794246
Adding some images
Browse files- .gitignore +4 -0
- app.py +23 -3
- bench.jpg +0 -0
- bus.jpg +0 -0
- flagged/Image/046c5ccdcb2d6d469d33/bench.jpg +0 -0
.gitignore
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.pt
|
2 |
+
output*
|
3 |
+
test*
|
4 |
+
.venv
|
app.py
CHANGED
@@ -1,9 +1,29 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
|
|
|
|
3 |
|
4 |
-
def greet(name):
|
5 |
-
return "Hello " + name + "!!"
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from ultralytics import YOLO
|
3 |
+
from PIL import Image
|
4 |
|
5 |
+
# Load a pretrained YOLOv8n model
|
6 |
+
model = YOLO("yolov8n.pt")
|
7 |
|
|
|
|
|
8 |
|
9 |
+
def main_function(lbd, img):
|
10 |
+
results = model(img) # predict on an image
|
11 |
+
r = results[0]
|
12 |
+
im_bgr = r.plot() # BGR-order numpy array
|
13 |
+
im_rgb = Image.fromarray(im_bgr[..., ::-1]) # RGB-order PIL image
|
14 |
+
new_img = im_rgb
|
15 |
+
# res = results[0].save(filename="output.jpg") # save the image
|
16 |
+
# # load image
|
17 |
+
# new_img = Image.open("output.jpg")
|
18 |
+
return new_img
|
19 |
|
20 |
+
|
21 |
+
iface = gr.Interface(
|
22 |
+
fn=main_function,
|
23 |
+
inputs=["slider", gr.Image(type="pil")],
|
24 |
+
outputs=gr.Image(type="pil"),
|
25 |
+
examples=[
|
26 |
+
[0, "bus.jpg"],
|
27 |
+
],
|
28 |
+
)
|
29 |
iface.launch()
|
bench.jpg
ADDED
![]() |
bus.jpg
ADDED
![]() |
flagged/Image/046c5ccdcb2d6d469d33/bench.jpg
ADDED
![]() |