liuyizhang commited on
Commit
6061d17
1 Parent(s): 8dd1f66

update app.py

Browse files
GroundingDINO/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 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):
 
10
  import torchvision.transforms as T
11
  import torchvision.transforms.functional as F
12
 
13
+ from GroundingDINO.groundingdino.util.box_ops import box_xyxy_to_cxcywh
14
+ from GroundingDINO.groundingdino.util.misc import interpolate
15
 
16
 
17
  def crop(image, target, region):
GroundingDINO/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 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,9 +33,9 @@ from Grounding_DINO.groundingdino.util.misc import (
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
 
23
  from torchvision.ops.boxes import nms
24
  from transformers import AutoTokenizer, BertModel, BertTokenizer, RobertaModel, RobertaTokenizerFast
25
 
26
+ from GroundingDINO.groundingdino.util import box_ops, get_tokenlizer
27
+ from GroundingDINO.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 GroundingDINO.groundingdino.util.utils import get_phrases_from_posmap
37
+ from GroundingDINO.groundingdino.util.visualizer import COCOVisualizer
38
+ from GroundingDINO.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,14 @@
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
 
@@ -26,11 +20,11 @@ import torch
26
  from PIL import Image, ImageDraw, ImageFont
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
 
1
 
2
  import subprocess, os, sys
3
 
4
+ sys.path.insert(0, './GroundingDINO')
 
 
 
 
 
 
5
 
6
  result = subprocess.run(['pip', 'list'], check=True)
7
+ print(f'pip list result = {result}')
8
 
9
  if not os.path.exists('./sam_vit_h_4b8939.pth'):
10
  result = subprocess.run(['wget', 'https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth'], check=True)
11
+ print(f'wget sam_vit_h_4b8939.pth result = {result}')
12
 
13
  import gradio as gr
14
 
 
20
  from PIL import Image, ImageDraw, ImageFont
21
 
22
  # Grounding DINO
23
+ import GroundingDINO.groundingdino.datasets.transforms as T
24
+ from GroundingDINO.groundingdino.models import build_model
25
+ from GroundingDINO.groundingdino.util import box_ops
26
+ from GroundingDINO.groundingdino.util.slconfig import SLConfig
27
+ from GroundingDINO.groundingdino.util.utils import clean_state_dict, get_phrases_from_posmap
28
 
29
  # segment anything
30
  from segment_anything import build_sam, SamPredictor
outputs/grounding_dino_output.jpg DELETED
Binary file (78.1 kB)
 
outputs/raw_image.jpg DELETED
Binary file (44.8 kB)