File size: 1,043 Bytes
70ec316
50b43f5
 
70ec316
50b43f5
70ec316
50b43f5
 
 
 
70ec316
50b43f5
 
 
 
b08f2d7
70ec316
50b43f5
70ec316
 
50b43f5
b08f2d7
01ff67a
b08f2d7
50b43f5
70ec316
b08f2d7
6446e68
b08f2d7
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
29
30
# 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}


# RUNNING WEB UI
import gradio as gr

image = gr.Image()
label = gr.Label(num_top_classes=5)

description = "## Categories: \n" + ", ".join(pipe.model.config.label2id.keys())
examples = [["samples/cycling.jpg"], ["samples/dancing.webp"], ["samples/listening music.png"], ["samples/running.jpg"], ["samples/sleeping.webp"]]
theme = gr.themes.Default(primary_hue="red", secondary_hue="pink")

gr.Interface(fn=classify_image, inputs=image, outputs=label, title='Human Action Recognition',
             description=description, examples=examples, theme=theme
            ).launch(height=1000, width=1600, debug=True)