File size: 760 Bytes
b964925
b218d0c
 
 
 
 
20afda5
 
 
b218d0c
 
 
20afda5
b218d0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

from transformers import pipeline
from transformers.utils import logging
import os
import gradio as gr
from PIL import Image
# Use a pipeline as a high-level helper
from transformers import pipeline




od_pipe = pipeline("object-detection", model="facebook/detr-resnet-50")

def get_pipeline_prediction(pil_image):
    
    pipeline_output = od_pipe(pil_image)
    
    processed_image = render_results_in_image(pil_image,
                                            pipeline_output)
    return processed_image

demo = 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")
)

demo.launch(share=False)