rvv-karma's picture
Update app.py
582d4fc
raw
history blame
927 Bytes
# rvv-karma/Human-Action-Recognition
## Creating prediction pipeline
from PIL import Image
from transformers import pipeline
pipe = pipeline("image-classification", "rvv-karma/Human-Action-Recognition-VIT-Base-patch16-224")
def classify_image(input):
image = Image.fromarray(input.astype('uint8'), 'RGB')
predictions = pipe(image)
return {prediction["label"]: prediction["score"] for prediction in predictions}
import gradio as gr
ex=[['cat2.jpg'],
['dog2.jpeg'],
['cat3.jpg'],
['dog.jpeg']]
ex = []
"""
## RUNNING WEB UI"""
image = gr.Image()
label = gr.Label(num_top_classes=5)
description = "Categories: " + "'" + "', '".join(pipe.model.config.label2id.keys()) + "'"
gr.Interface(fn=classify_image, inputs=image, outputs=label, title='Human Action Recognition',
description=description, examples=ex, theme='peach').launch(height=1000, width=1600, debug=True, share=True)