File size: 945 Bytes
b5955cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
508dd84
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
import gradio as gr
from crowd_counter import CrowdCounter
from PIL import Image
import cv2

crowd_counter_engine = CrowdCounter()

def predict(inp):
    inp = Image.fromarray(inp.astype('uint8'), 'RGB')
    response = crowd_counter_engine.inference(inp)
    crowd_count = response[0]
    pred_img= response[1]
    return cv2.cvtColor(pred_img, cv2.COLOR_BGR2RGB), crowd_count

title = "Crowd Counter Demo"
desc = "A Demo of Proposal Point Prediction for Crowd Counting - Powered by P2PNet"
examples = [
    ["images/img-1.jpg"],
    ["images/img-2.jpg"],
    ["images/img-3.jpg"],
]
inputs = gr.inputs.Image(label="Image of Crowd")
outputs = [gr.outputs.Image(label="Proposal Points Prediction",type = "numpy"), gr.outputs.Label(label="Predicted Count",type = "numpy")]
gr.Interface(fn=predict, inputs=inputs, outputs=outputs, title=title, description=desc, examples=examples,
             allow_flagging=False).launch()