File size: 1,018 Bytes
392fac9
 
 
 
 
 
79183dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
try:
    import detectron2
except:
    import os 
    os.system('pip install git+https://github.com/facebookresearch/detectron2.git')

import gradio as gr
import json
import numpy as np
from sam_utils import grounded_segmentation, create_yellow_background_with_insects
from yolo_utils import yolo_processimage
from detectron_utils import detectron_process_image
def process_image(image, include_json):
    detectron_result=detectron_process_image(image)
    yolo_result = yolo_processimage(image)
    insectsam_result = create_yellow_background_with_insects(image)

    return insectsam_result, yolo_result, detectron_result

examples = [
    ["demo.jpg"]
]

gr.Interface(
    fn=process_image,
    inputs=[gr.Image(type="pil"), gr.Checkbox(label="Include JSON", value=False)],
    outputs=[gr.Image(label='InsectSAM', type="numpy"),
             gr.Image(label='Yolov8', type="numpy"),
             gr.Image(label='Detectron', type="numpy")],
    title="RB-IBDM Model Zoo Demo 🐞",
    examples=examples
).launch()