import tensorflow as tf import cv2 import numpy as np from glob import glob # from models import Yolov4 import gradio as gr # model = Yolov4(weight_path="best.pt", class_name_path='coco_classes.txt') from ultralytics import YOLO # Load a model model = YOLO("best.pt") # load a custom model # Predict with the model # results = model("image.jpg", save = True) # predict on an image def gradio_wrapper(img): global model #print(np.shape(img)) results = model.predict(img) # predict on an image return cv2.putText(img, str(results[0]), cv2.LINE_AA, False) demo = gr.Interface( gradio_wrapper, #gr.Image(source="webcam", streaming=True, flip=True), gr.Image(source="webcam", streaming=True), "image", live=True ) demo.launch()