Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import os
|
2 |
os.system('!python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu113/torch1.10/index.html')
|
3 |
-
os.system('!git clone -b add_dit_inference_bis https://github.com/NielsRogge/unilm.git')
|
4 |
|
5 |
import cv2
|
6 |
-
|
|
|
7 |
from detectron2.config import get_cfg
|
8 |
from detectron2.utils.visualizer import ColorMode, Visualizer
|
9 |
from detectron2.data import MetadataCatalog
|
@@ -12,6 +12,37 @@ from detectron2.engine import DefaultPredictor
|
|
12 |
import gradio as gr
|
13 |
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# Step 1: instantiate config
|
16 |
cfg = get_cfg()
|
17 |
add_vit_config(cfg)
|
|
|
1 |
import os
|
2 |
os.system('!python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu113/torch1.10/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
|
9 |
from detectron2.data import MetadataCatalog
|
|
|
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)
|