Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,40 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import PIL.Image as Image
|
|
|
|
| 3 |
from ultralytics import ASSETS, YOLO
|
| 4 |
|
| 5 |
model = YOLO("https://huggingface.co/spaces/gpbhupinder/test/blob/main/model_-%2023%20june%202024%2019_22.pt")
|
| 6 |
|
|
|
|
| 7 |
def predict_image(img):
|
| 8 |
"""Predicts objects in an image using a YOLOv8 model."""
|
| 9 |
results = model.predict(
|
| 10 |
source=img,
|
|
|
|
| 11 |
show_labels=True,
|
| 12 |
show_conf=True,
|
| 13 |
imgsz=640,
|
|
|
|
| 14 |
)
|
| 15 |
-
|
| 16 |
for r in results:
|
| 17 |
im_array = r.plot()
|
| 18 |
im = Image.fromarray(im_array[..., ::-1])
|
| 19 |
-
|
| 20 |
return im
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
iface = gr.Interface(
|
| 23 |
fn=predict_image,
|
| 24 |
inputs=[
|
| 25 |
gr.Image(type="pil", label="Upload Image"),
|
|
|
|
|
|
|
| 26 |
],
|
| 27 |
-
outputs=
|
| 28 |
-
gr.Image(type="pil", label="Result"),
|
| 29 |
-
gr.Textbox(label="Predictions")
|
| 30 |
-
],
|
| 31 |
title="GP Wolf Classifier",
|
| 32 |
description="Upload images for inference.",
|
| 33 |
examples=[
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import PIL.Image as Image
|
| 3 |
+
|
| 4 |
from ultralytics import ASSETS, YOLO
|
| 5 |
|
| 6 |
model = YOLO("https://huggingface.co/spaces/gpbhupinder/test/blob/main/model_-%2023%20june%202024%2019_22.pt")
|
| 7 |
|
| 8 |
+
|
| 9 |
def predict_image(img):
|
| 10 |
"""Predicts objects in an image using a YOLOv8 model."""
|
| 11 |
results = model.predict(
|
| 12 |
source=img,
|
| 13 |
+
|
| 14 |
show_labels=True,
|
| 15 |
show_conf=True,
|
| 16 |
imgsz=640,
|
| 17 |
+
|
| 18 |
)
|
| 19 |
+
|
| 20 |
for r in results:
|
| 21 |
im_array = r.plot()
|
| 22 |
im = Image.fromarray(im_array[..., ::-1])
|
| 23 |
+
|
| 24 |
return im
|
| 25 |
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
iface = gr.Interface(
|
| 31 |
fn=predict_image,
|
| 32 |
inputs=[
|
| 33 |
gr.Image(type="pil", label="Upload Image"),
|
| 34 |
+
# gr.Slider(minimum=0, maximum=1, value=0.25, label="Confidence threshold"),
|
| 35 |
+
# gr.Slider(minimum=0, maximum=1, value=0.45, label="IoU threshold"),
|
| 36 |
],
|
| 37 |
+
outputs=gr.Image(type="pil", label="Result"),
|
|
|
|
|
|
|
|
|
|
| 38 |
title="GP Wolf Classifier",
|
| 39 |
description="Upload images for inference.",
|
| 40 |
examples=[
|