import gradio as gr from transformers import pipeline pipe = pipeline("object-detection", model="microsoft/table-transformer-detection") def detect_objects(image): result = pipe(image) return [{"label": item["label"], "score": item["score"], "box": item["box"]} for item in result] app = gr.Interface( fn=detect_objects, inputs=gr.Image(type="filepath"), outputs=gr.JSON(), title="Object Detection", description="Upload an image to detect objects using Microsoft's Table Transformer model." ) # Launch the app if __name__ == "__main__": app.launch()