File size: 1,074 Bytes
54ef3d0
03e6add
369ae33
6564a3a
c21a752
6564a3a
 
 
 
 
 
 
 
dba19bd
c21a752
bf4a295
c21a752
bf4a295
c21a752
 
6564a3a
c21a752
 
bf4a295
c21a752
 
 
 
 
 
 
 
bf4a295
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
32
33
import os
import gradio as gr
from transformers import pipeline
from transformers import DetrForSegmentation, DetrConfig

# Initialize the configuration for DetrForObjectDetection
config = DetrConfig.from_pretrained("facebook/detr-resnet-50")

# Create the model for object detection using the specified configuration
model = DetrForSegmentation.from_pretrained("facebook/detr-resnet-50", config=config)

# Updated function call
results = processed_image(model, image, size={'longest_edge': 800})

def get_pipeline_prediction(pil_image):
    # first get the pipeline output given the pil image
    pipeline_output = od_pipe(pil_image)
    # Then Process the image using the pipeline output
    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