ProyectoVision commited on
Commit
1c1cecc
·
1 Parent(s): b5ee46e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -1,9 +1,26 @@
1
  import gradio as gr
2
  import os
3
-
 
 
 
4
 
5
  def image_mod(image):
6
- return image.rotate(45)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  demo = gr.Interface(
9
  image_mod,
 
1
  import gradio as gr
2
  import os
3
+ from PIL import Image
4
+ from ultralytics import YOLO
5
+ import cv2 as cv
6
+ import numpy as np
7
 
8
  def image_mod(image):
9
+
10
+ # Load a pretrained YOLOv8n model
11
+ model = YOLO('/Modelo/MN_detect_last.pt')
12
+
13
+ img = cv.imread(image)
14
+ img = cv.resize(img, (640, 640))
15
+ results = model(img, conf=0.60) # results list
16
+
17
+ # Show the results
18
+ for r in results:
19
+ im_array = r.plot() # plot a BGR numpy array of predictions
20
+ im = Image.fromarray(im_array[..., ::-1]) # RGB PIL image
21
+ im.show() # show image
22
+
23
+ return im
24
 
25
  demo = gr.Interface(
26
  image_mod,