Update app.py
Browse files
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
|
26 |
-
|
27 |
-
|
28 |
-
pass
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
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"),
|