Spaces:
Sleeping
Sleeping
from transformers import pipeline | |
import gradio as gr | |
# Load a pre-trained image classification model | |
model = pipeline("image-classification", model="google/vit-base-patch16-224") | |
# Define a function for detecting actions | |
def classify_image(image): | |
predictions = model(image) | |
return {pred["label"]: round(pred["score"], 4) for pred in predictions} | |
# Gradio interface | |
interface = gr.Interface( | |
fn=classify_image, | |
inputs=gr.Image(type="pil"), # Accepts image input | |
outputs="json", # Outputs predictions | |
title="Action Classifier", | |
description="Upload an image, and the model will classify actions (e.g., standing, sitting)." | |
) | |
# Launch the app | |
if __name__ == "__main__": | |
interface.launch(server_name="0.0.0.0") | |