File size: 751 Bytes
5bf84ff
 
 
 
 
9b1d8f1
5bf84ff
 
 
 
9b1d8f1
 
 
 
 
 
 
 
 
 
 
5bf84ff
 
 
9b1d8f1
5bf84ff
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
import yolov5
import os
from transformers import pipeline

#ImageClassifier = pipeline(task="image-classification", model="")

model = yolov5.load('./gentle-meadow.pt', device='cpu')

def predict(image):
   results = model([image], size=224)
    #predictions = imageClassifier(image)
    # classMappings = {
    #     'police': "Police / Authorized Personnel",
    #     'public': 'Unauthorized Person'
    # }
    # output = {}
    # for item in predictions:
    #     output[classMappings[item['label']]] = item['score']

    return results.render()[0]

demo = gr.Interface(fn=predict, 
             inputs=gr.inputs.Image(type="pil"),
             outputs=gr.outputs.Image(type="pil"),
             )
             
demo.launch()