Spaces:
Sleeping
Sleeping
File size: 746 Bytes
5b5f841 e5257aa 5b5f841 e5257aa 5b5f841 e5257aa 5b5f841 e5257aa 5b5f841 e5257aa 5b5f841 e5257aa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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")
|