Spaces:
Runtime error
Runtime error
liuyizhang
commited on
Commit
·
5c0bd4c
1
Parent(s):
fd01170
update app.py
Browse files
Grounding_DINO/groundingdino/datasets/transforms.py
CHANGED
|
@@ -10,8 +10,8 @@ import torch
|
|
| 10 |
import torchvision.transforms as T
|
| 11 |
import torchvision.transforms.functional as F
|
| 12 |
|
| 13 |
-
from groundingdino.util.box_ops import box_xyxy_to_cxcywh
|
| 14 |
-
from groundingdino.util.misc import interpolate
|
| 15 |
|
| 16 |
|
| 17 |
def crop(image, target, region):
|
|
|
|
| 10 |
import torchvision.transforms as T
|
| 11 |
import torchvision.transforms.functional as F
|
| 12 |
|
| 13 |
+
from Grounding_DINO.groundingdino.util.box_ops import box_xyxy_to_cxcywh
|
| 14 |
+
from Grounding_DINO.groundingdino.util.misc import interpolate
|
| 15 |
|
| 16 |
|
| 17 |
def crop(image, target, region):
|
Grounding_DINO/groundingdino/models/GroundingDINO/groundingdino.py
CHANGED
|
@@ -23,8 +23,8 @@ from torch import nn
|
|
| 23 |
from torchvision.ops.boxes import nms
|
| 24 |
from transformers import AutoTokenizer, BertModel, BertTokenizer, RobertaModel, RobertaTokenizerFast
|
| 25 |
|
| 26 |
-
from groundingdino.util import box_ops, get_tokenlizer
|
| 27 |
-
from groundingdino.util.misc import (
|
| 28 |
NestedTensor,
|
| 29 |
accuracy,
|
| 30 |
get_world_size,
|
|
@@ -33,9 +33,9 @@ from groundingdino.util.misc import (
|
|
| 33 |
is_dist_avail_and_initialized,
|
| 34 |
nested_tensor_from_tensor_list,
|
| 35 |
)
|
| 36 |
-
from groundingdino.util.utils import get_phrases_from_posmap
|
| 37 |
-
from groundingdino.util.visualizer import COCOVisualizer
|
| 38 |
-
from groundingdino.util.vl_utils import create_positive_map_from_span
|
| 39 |
|
| 40 |
from ..registry import MODULE_BUILD_FUNCS
|
| 41 |
from .backbone import build_backbone
|
|
|
|
| 23 |
from torchvision.ops.boxes import nms
|
| 24 |
from transformers import AutoTokenizer, BertModel, BertTokenizer, RobertaModel, RobertaTokenizerFast
|
| 25 |
|
| 26 |
+
from Grounding_DINO.groundingdino.util import box_ops, get_tokenlizer
|
| 27 |
+
from Grounding_DINO.groundingdino.util.misc import (
|
| 28 |
NestedTensor,
|
| 29 |
accuracy,
|
| 30 |
get_world_size,
|
|
|
|
| 33 |
is_dist_avail_and_initialized,
|
| 34 |
nested_tensor_from_tensor_list,
|
| 35 |
)
|
| 36 |
+
from Grounding_DINO.groundingdino.util.utils import get_phrases_from_posmap
|
| 37 |
+
from Grounding_DINO.groundingdino.util.visualizer import COCOVisualizer
|
| 38 |
+
from Grounding_DINO.groundingdino.util.vl_utils import create_positive_map_from_span
|
| 39 |
|
| 40 |
from ..registry import MODULE_BUILD_FUNCS
|
| 41 |
from .backbone import build_backbone
|
app.py
CHANGED
|
@@ -1,20 +1,21 @@
|
|
| 1 |
|
| 2 |
import subprocess, os, sys
|
| 3 |
|
| 4 |
-
if 0==
|
| 5 |
-
result = subprocess.run(['pip', 'install', '-e', 'segment_anything'], check=True)
|
| 6 |
-
print(f'liuyz_install segment_anything result = {result}')
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
| 10 |
result = subprocess.run(['pip', 'list'], check=True)
|
| 11 |
print(f'liuyz_pip list result = {result}')
|
| 12 |
|
| 13 |
-
if not os.path.exists('
|
| 14 |
result = subprocess.run(['wget', 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth'], check=True)
|
| 15 |
print(f'liuyz_wget sam_vit_h_4b8939.pth result = {result}')
|
| 16 |
|
| 17 |
-
|
| 18 |
import gradio as gr
|
| 19 |
|
| 20 |
import argparse
|
|
@@ -26,10 +27,10 @@ from PIL import Image, ImageDraw, ImageFont
|
|
| 26 |
|
| 27 |
# Grounding DINO
|
| 28 |
import Grounding_DINO.groundingdino.datasets.transforms as T
|
| 29 |
-
from groundingdino.models import build_model
|
| 30 |
-
from groundingdino.util import box_ops
|
| 31 |
-
from groundingdino.util.slconfig import SLConfig
|
| 32 |
-
from groundingdino.util.utils import clean_state_dict, get_phrases_from_posmap
|
| 33 |
|
| 34 |
# segment anything
|
| 35 |
from segment_anything import build_sam, SamPredictor
|
|
|
|
| 1 |
|
| 2 |
import subprocess, os, sys
|
| 3 |
|
| 4 |
+
if 0==0:
|
| 5 |
+
# result = subprocess.run(['pip', 'install', '-e', 'segment_anything'], check=True)
|
| 6 |
+
# print(f'liuyz_install segment_anything result = {result}')
|
| 7 |
+
|
| 8 |
+
sys.path.insert(0, './Grounding_DINO')
|
| 9 |
+
# result = subprocess.run(['pip', 'install', '-e', 'Grounding_DINO'], check=True)
|
| 10 |
+
# print(f'liuyz_install Grounding_DINO result = {result}')
|
| 11 |
|
| 12 |
result = subprocess.run(['pip', 'list'], check=True)
|
| 13 |
print(f'liuyz_pip list result = {result}')
|
| 14 |
|
| 15 |
+
if not os.path.exists('./sam_vit_h_4b8939.pth'):
|
| 16 |
result = subprocess.run(['wget', 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth'], check=True)
|
| 17 |
print(f'liuyz_wget sam_vit_h_4b8939.pth result = {result}')
|
| 18 |
|
|
|
|
| 19 |
import gradio as gr
|
| 20 |
|
| 21 |
import argparse
|
|
|
|
| 27 |
|
| 28 |
# Grounding DINO
|
| 29 |
import Grounding_DINO.groundingdino.datasets.transforms as T
|
| 30 |
+
from Grounding_DINO.groundingdino.models import build_model
|
| 31 |
+
from Grounding_DINO.groundingdino.util import box_ops
|
| 32 |
+
from Grounding_DINO.groundingdino.util.slconfig import SLConfig
|
| 33 |
+
from Grounding_DINO.groundingdino.util.utils import clean_state_dict, get_phrases_from_posmap
|
| 34 |
|
| 35 |
# segment anything
|
| 36 |
from segment_anything import build_sam, SamPredictor
|
requirements.txt
CHANGED
|
@@ -20,6 +20,6 @@ transformers
|
|
| 20 |
yapf
|
| 21 |
numba
|
| 22 |
segment_anything
|
| 23 |
-
git+https://github.com/IDEA-Research/GroundingDINO
|
| 24 |
# GroundingDINO
|
| 25 |
# segment_anything
|
|
|
|
| 20 |
yapf
|
| 21 |
numba
|
| 22 |
segment_anything
|
| 23 |
+
# git+https://github.com/IDEA-Research/GroundingDINO
|
| 24 |
# GroundingDINO
|
| 25 |
# segment_anything
|