Spaces:
Running
Running
Martin Tomov
commited on
Commit
β’
11b09ed
1
Parent(s):
880a696
rm spaces
Browse files
app.py
CHANGED
@@ -1,42 +1,21 @@
|
|
1 |
-
import spaces # on top as CUDA needs to be initialized after `spaces`
|
2 |
-
import os
|
3 |
-
|
4 |
try:
|
5 |
import detectron2
|
6 |
-
except
|
7 |
-
import os
|
8 |
os.system('pip install git+https://github.com/facebookresearch/detectron2.git')
|
9 |
|
10 |
-
try:
|
11 |
-
from segment_anything import build_sam, SamPredictor
|
12 |
-
except ImportError:
|
13 |
-
import os
|
14 |
-
os.system('pip install git+https://github.com/facebookresearch/segment-anything.git')
|
15 |
-
from segment_anything import build_sam, SamPredictor
|
16 |
-
|
17 |
-
try:
|
18 |
-
import grounded_dino
|
19 |
-
except ImportError:
|
20 |
-
import os
|
21 |
-
os.system('pip install transformers')
|
22 |
-
os.system('pip install git+https://github.com/IDEA-Research/GroundingDINO.git')
|
23 |
-
|
24 |
import gradio as gr
|
25 |
import json
|
26 |
import numpy as np
|
27 |
from sam_utils import grounded_segmentation, create_yellow_background_with_insects
|
28 |
from yolo_utils import yolo_processimage
|
29 |
from detectron_utils import detectron_process_image
|
30 |
-
from gsl_utils import gsl_process_image
|
31 |
-
|
32 |
-
@spaces.GPU
|
33 |
def process_image(image, include_json):
|
34 |
-
detectron_result
|
35 |
yolo_result = yolo_processimage(image)
|
36 |
insectsam_result = create_yellow_background_with_insects(image)
|
37 |
-
gsl_result = gsl_process_image(image)
|
38 |
|
39 |
-
return insectsam_result, yolo_result, detectron_result
|
40 |
|
41 |
examples = [
|
42 |
["imgs/demo.jpg"],
|
@@ -50,12 +29,9 @@ examples = [
|
|
50 |
gr.Interface(
|
51 |
fn=process_image,
|
52 |
inputs=[gr.Image(type="pil")],
|
53 |
-
outputs=[
|
54 |
-
|
55 |
-
|
56 |
-
gr.Image(label='Detectron', type="numpy"),
|
57 |
-
gr.Image(label='GSL', type="numpy")
|
58 |
-
],
|
59 |
title="Insect Model Zoo ππ¬",
|
60 |
examples=examples
|
61 |
-
).launch()
|
|
|
|
|
|
|
|
|
1 |
try:
|
2 |
import detectron2
|
3 |
+
except:
|
4 |
+
import os
|
5 |
os.system('pip install git+https://github.com/facebookresearch/detectron2.git')
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
import gradio as gr
|
8 |
import json
|
9 |
import numpy as np
|
10 |
from sam_utils import grounded_segmentation, create_yellow_background_with_insects
|
11 |
from yolo_utils import yolo_processimage
|
12 |
from detectron_utils import detectron_process_image
|
|
|
|
|
|
|
13 |
def process_image(image, include_json):
|
14 |
+
detectron_result=detectron_process_image(image)
|
15 |
yolo_result = yolo_processimage(image)
|
16 |
insectsam_result = create_yellow_background_with_insects(image)
|
|
|
17 |
|
18 |
+
return insectsam_result, yolo_result, detectron_result
|
19 |
|
20 |
examples = [
|
21 |
["imgs/demo.jpg"],
|
|
|
29 |
gr.Interface(
|
30 |
fn=process_image,
|
31 |
inputs=[gr.Image(type="pil")],
|
32 |
+
outputs=[gr.Image(label='InsectSAM', type="numpy"),
|
33 |
+
gr.Image(label='Yolov8', type="numpy"),
|
34 |
+
gr.Image(label='Detectron', type="numpy")],
|
|
|
|
|
|
|
35 |
title="Insect Model Zoo ππ¬",
|
36 |
examples=examples
|
37 |
+
).launch()
|