Spaces:
Runtime error
Runtime error
detection model added
Browse files
app.py
CHANGED
@@ -1,7 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
demo
|
7 |
-
demo.launch()
|
|
|
1 |
+
# import gradio as gr
|
2 |
+
|
3 |
+
# def greet(name):
|
4 |
+
# return "Hello " + name + "!!"
|
5 |
+
|
6 |
+
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
+
# demo.launch()
|
8 |
+
|
9 |
import gradio as gr
|
10 |
+
from ultralytics import YOLO
|
11 |
+
from PIL import Image
|
12 |
+
|
13 |
+
#Load model
|
14 |
+
model = YOLO('yolov8n.pt')
|
15 |
+
|
16 |
+
def image_display(input_image):
|
17 |
+
# Return the input image as the output
|
18 |
+
model = YOLO('yolov8n.pt')
|
19 |
+
results = model(input_image)
|
20 |
+
for r in results:
|
21 |
+
im_array = r.plot() # plot a BGR numpy array of predictions
|
22 |
+
im = Image.fromarray(im_array[..., ::-1]) # RGB PIL image
|
23 |
+
|
24 |
+
return im_array
|
25 |
+
|
26 |
+
input_component = gr.inputs.Image()
|
27 |
+
output_component = gr.outputs.Image()
|
28 |
+
|
29 |
+
# Create the Gradio interface
|
30 |
+
gr.Interface(
|
31 |
+
fn=image_display,
|
32 |
+
inputs=input_component,
|
33 |
+
outputs=output_component,
|
34 |
+
title="Image Display App",
|
35 |
+
description="Upload an image and see it displayed.",
|
36 |
+
theme="compact"
|
37 |
+
).launch(share=True)
|
38 |
+
|
39 |
+
|
40 |
|
41 |
+
# demo = gr.Interface(
|
42 |
+
# fn=greet,
|
43 |
+
# inputs='textbox',
|
44 |
+
# outputs='textbox',
|
45 |
+
# )
|
46 |
|
47 |
+
# demo.launch()
|
|