Views
No views yet

Human-Action-Recognition is an image classification vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for multi-class human action recognition. It uses the SiglipForImageClassification architecture to predict human activities from still images.
1Classification Report:
2 precision recall f1-score support
3
4 calling 0.8525 0.7571 0.8020 840
5 clapping 0.8679 0.7119 0.7822 840
6 cycling 0.9662 0.9857 0.9758 840
7 dancing 0.8302 0.8381 0.8341 840
8 drinking 0.9093 0.8714 0.8900 840
9 eating 0.9377 0.9131 0.9252 840
10 fighting 0.9034 0.7905 0.8432 840
11 hugging 0.9065 0.9000 0.9032 840
12 laughing 0.7854 0.8583 0.8203 840
13listening_to_music 0.8494 0.7988 0.8233 840
14 running 0.8888 0.9321 0.9099 840
15 sitting 0.5945 0.7226 0.6523 840
16 sleeping 0.8593 0.8214 0.8399 840
17 texting 0.8195 0.6702 0.7374 840
18 using_laptop 0.6610 0.9190 0.7689 840
19
20 accuracy 0.8327 12600
21 macro avg 0.8421 0.8327 0.8339 12600
22 weighted avg 0.8421 0.8327 0.8339 12600
!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor, SiglipForImageClassification
3from PIL import Image
4import torch
5
6# Load model and processor
7model_name = "prithivMLmods/Human-Action-Recognition" # Change to your updated model path
8model = SiglipForImageClassification.from_pretrained(model_name)
9processor = AutoImageProcessor.from_pretrained(model_name)
10
11# ID to Label mapping
12id2label = {
13 0: "calling",
14 1: "clapping",
15 2: "cycling",
16 3: "dancing",
17 4: "drinking",
18 5: "eating",
19 6: "fighting",
20 7: "hugging",
21 8: "laughing",
22 9: "listening_to_music",
23 10: "running",
24 11: "sitting",
25 12: "sleeping",
26 13: "texting",
27 14: "using_laptop"
28}
29
30def classify_action(image):
31 """Predicts the human action in the image."""
32 image = Image.fromarray(image).convert("RGB")
33 inputs = processor(images=image, return_tensors="pt")
34
35 with torch.no_grad():
36 outputs = model(**inputs)
37 logits = outputs.logits
38 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
39
40 predictions = {id2label[i]: round(probs[i], 3) for i in range(len(probs))}
41 return predictions
42
43# Gradio interface
44iface = gr.Interface(
45 fn=classify_action,
46 inputs=gr.Image(type="numpy"),
47 outputs=gr.Label(label="Action Prediction Scores"),
48 title="Human Action Recognition",
49 description="Upload an image to recognize the human action (e.g., dancing, calling, sitting, etc.)."
50)
51
52# Launch the app
53if __name__ == "__main__":
54 iface.launch()