Spaces:
Sleeping
Sleeping
| # 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_data): | |
| image = Image.fromarray(input_data.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) | |