import gradio as gr from transformers import pipeline from detection_utils import render_results_in_image, summarize_predictions_natural_language obj_detector = pipeline( task = "object-detection", model = "facebook/detr-resnet-50" ) def get_pipeline_prediction(pil_image): pipeline_output = obj_detector(pil_image) processed_image = render_results_in_image( pil_image, pipeline_output ) detection_summary = summarize_predictions_natural_language(pipeline_output) return processed_image, detection_summary detection_interface = gr.Interface( fn = get_pipeline_prediction, inputs = gr.Image( label = "Input Image", type = 'pil' ), outputs = [gr.Image( label = "Output image with predicted instances", type = 'pil' ), gr.Textbox(label="Detection Summary")], allow_flagging = 'never' ) # Add Markdown content markdown_content_detection = gr.Markdown( """