Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,14 @@
|
|
1 |
import os
|
2 |
os.system('pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html')
|
|
|
|
|
|
|
|
|
3 |
|
4 |
import cv2
|
5 |
|
|
|
|
|
6 |
from detectron2.config import CfgNode as CN
|
7 |
from detectron2.config import get_cfg
|
8 |
from detectron2.utils.visualizer import ColorMode, Visualizer
|
@@ -12,37 +18,6 @@ from detectron2.engine import DefaultPredictor
|
|
12 |
import gradio as gr
|
13 |
|
14 |
|
15 |
-
def add_vit_config(cfg):
|
16 |
-
"""
|
17 |
-
Add config for VIT.
|
18 |
-
"""
|
19 |
-
_C = cfg
|
20 |
-
|
21 |
-
_C.MODEL.VIT = CN()
|
22 |
-
|
23 |
-
# CoaT model name.
|
24 |
-
_C.MODEL.VIT.NAME = ""
|
25 |
-
|
26 |
-
# Output features from CoaT backbone.
|
27 |
-
_C.MODEL.VIT.OUT_FEATURES = ["layer3", "layer5", "layer7", "layer11"]
|
28 |
-
|
29 |
-
_C.MODEL.VIT.IMG_SIZE = [224, 224]
|
30 |
-
|
31 |
-
_C.MODEL.VIT.POS_TYPE = "shared_rel"
|
32 |
-
|
33 |
-
_C.MODEL.VIT.DROP_PATH = 0.
|
34 |
-
|
35 |
-
_C.MODEL.VIT.MODEL_KWARGS = "{}"
|
36 |
-
|
37 |
-
_C.SOLVER.OPTIMIZER = "ADAMW"
|
38 |
-
|
39 |
-
_C.SOLVER.BACKBONE_MULTIPLIER = 1.0
|
40 |
-
|
41 |
-
_C.AUG = CN()
|
42 |
-
|
43 |
-
_C.AUG.DETR = False
|
44 |
-
|
45 |
-
|
46 |
# Step 1: instantiate config
|
47 |
cfg = get_cfg()
|
48 |
add_vit_config(cfg)
|
|
|
1 |
import os
|
2 |
os.system('pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html')
|
3 |
+
os.system("git clone https://github.com/microsoft/unilm.git")
|
4 |
+
|
5 |
+
import sys
|
6 |
+
sys.path.append("unilm")
|
7 |
|
8 |
import cv2
|
9 |
|
10 |
+
from unilm.dit.object_detection.ditod import add_vit_config
|
11 |
+
|
12 |
from detectron2.config import CfgNode as CN
|
13 |
from detectron2.config import get_cfg
|
14 |
from detectron2.utils.visualizer import ColorMode, Visualizer
|
|
|
18 |
import gradio as gr
|
19 |
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
# Step 1: instantiate config
|
22 |
cfg = get_cfg()
|
23 |
add_vit_config(cfg)
|