skallewag commited on
Commit
9fd2d8a
·
verified ·
1 Parent(s): c6d282a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -27
app.py CHANGED
@@ -22,41 +22,51 @@ print(f"Python version: {sys.version}")
22
 
23
  # Create mock detectron2 structures to prevent import errors
24
  print("Setting up mock detectron2 module")
25
- class MockDetectron2Structures:
26
- class Boxes:
27
- def __init__(self, *args, **kwargs):
28
- pass
29
 
30
- class ImageList:
31
- def __init__(self, *args, **kwargs):
32
- pass
33
-
34
- @staticmethod
35
- def from_tensors(*args, **kwargs):
36
- return MockDetectron2Structures.ImageList()
37
 
38
- class Instances:
39
- def __init__(self, *args, **kwargs):
40
- pass
41
 
42
- class BitMasks:
43
- def __init__(self, *args, **kwargs):
44
- pass
45
-
46
- @staticmethod
47
- def from_polygon_masks(*args, **kwargs):
48
- return MockDetectron2Structures.BitMasks()
49
 
50
- class BoxMode:
51
- XYXY_ABS = 0
52
- XYWH_ABS = 1
53
 
54
- # Add mock detectron2 to sys.modules
55
  if 'detectron2' not in sys.modules:
56
  import types
57
  detectron2_module = types.ModuleType('detectron2')
 
58
  sys.modules['detectron2'] = detectron2_module
59
- detectron2_module.structures = MockDetectron2Structures
 
 
 
 
 
 
 
 
 
 
60
  print("Mock detectron2 module created")
61
 
62
  # Make sure utils directory exists
@@ -438,7 +448,7 @@ description = f"""
438
  article = "SEEM Demo" + (" (Simplified Interface)" if not model_loaded else "")
439
  inputs = [
440
  gr.Image(label="[Stroke] Draw on Image", type="pil"),
441
- gr.inputs.CheckboxGroup(choices=["Stroke", "Example", "Text", "Audio", "Video", "Panoptic"], type="value", label="Interactive Mode"),
442
  gr.Image(label="[Example] Draw on Referring Image", type="pil"),
443
  gr.Textbox(label="[Text] Referring Text"),
444
  gr.Audio(label="[Audio] Referring Audio", source="microphone", type="filepath"),
 
22
 
23
  # Create mock detectron2 structures to prevent import errors
24
  print("Setting up mock detectron2 module")
25
+ class Boxes:
26
+ def __init__(self, *args, **kwargs):
27
+ pass
 
28
 
29
+ class ImageList:
30
+ def __init__(self, *args, **kwargs):
31
+ pass
32
+
33
+ @staticmethod
34
+ def from_tensors(*args, **kwargs):
35
+ return ImageList()
36
 
37
+ class Instances:
38
+ def __init__(self, *args, **kwargs):
39
+ pass
40
 
41
+ class BitMasks:
42
+ def __init__(self, *args, **kwargs):
43
+ pass
44
+
45
+ @staticmethod
46
+ def from_polygon_masks(*args, **kwargs):
47
+ return BitMasks()
48
 
49
+ class BoxMode:
50
+ XYXY_ABS = 0
51
+ XYWH_ABS = 1
52
 
53
+ # Add mock detectron2 to sys.modules as a proper package
54
  if 'detectron2' not in sys.modules:
55
  import types
56
  detectron2_module = types.ModuleType('detectron2')
57
+ structures_module = types.ModuleType('detectron2.structures')
58
  sys.modules['detectron2'] = detectron2_module
59
+ sys.modules['detectron2.structures'] = structures_module
60
+
61
+ # Add classes to structures module
62
+ structures_module.Boxes = Boxes
63
+ structures_module.ImageList = ImageList
64
+ structures_module.Instances = Instances
65
+ structures_module.BitMasks = BitMasks
66
+ structures_module.BoxMode = BoxMode
67
+
68
+ # Set structures as an attribute of detectron2
69
+ detectron2_module.structures = structures_module
70
  print("Mock detectron2 module created")
71
 
72
  # Make sure utils directory exists
 
448
  article = "SEEM Demo" + (" (Simplified Interface)" if not model_loaded else "")
449
  inputs = [
450
  gr.Image(label="[Stroke] Draw on Image", type="pil"),
451
+ gr.CheckboxGroup(choices=["Stroke", "Example", "Text", "Audio", "Video", "Panoptic"], label="Interactive Mode"),
452
  gr.Image(label="[Example] Draw on Referring Image", type="pil"),
453
  gr.Textbox(label="[Text] Referring Text"),
454
  gr.Audio(label="[Audio] Referring Audio", source="microphone", type="filepath"),