InsectModelZoo / app.py
Martin Tomov
pip install git+https://github.com/IDEA-Research/Grounded-Segment-Anything.git from notebook
cd7cf5e verified
raw
history blame
1.72 kB
try:
import detectron2
except ImportError:
import os
os.system('pip install git+https://github.com/facebookresearch/detectron2.git')
try:
from segment_anything import build_sam, SamPredictor
except ImportError:
import os
os.system('pip install git+https://github.com/facebookresearch/segment-anything.git')
from segment_anything import build_sam, SamPredictor
try:
from GroundingDINO.groundingdino.util import box_ops
except ImportError:
import os
os.system('pip install git+https://github.com/IDEA-Research/Grounded-Segment-Anything.git')
from GroundingDINO.groundingdino.util import box_ops
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
from gsl_utils import gsl_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)
gsl_result = gsl_process_image(image)
return insectsam_result, yolo_result, detectron_result, gsl_result
examples = [
["demo.jpg"],
["demo1.jpg"],
["demo2.jpg"],
["demo3.jpg"],
["demo4.jpg"],
["demo5.jpg"],
]
gr.Interface(
fn=process_image,
inputs=[gr.Image(type="pil")],
outputs=[
gr.Image(label='InsectSAM', type="numpy"),
gr.Image(label='Yolov8', type="numpy"),
gr.Image(label='Detectron', type="numpy"),
gr.Image(label='GSL', type="numpy")
],
title="Insect Model Zoo πŸžπŸ”¬",
examples=examples
).launch()