Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,12 @@ import matplotlib.pyplot as plt
|
|
| 5 |
import warnings
|
| 6 |
warnings.filterwarnings("ignore")
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# ββ Standard imports βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 9 |
import gradio as gr
|
| 10 |
import numpy as np
|
|
@@ -12,7 +18,7 @@ import cv2
|
|
| 12 |
import io
|
| 13 |
from PIL import Image
|
| 14 |
|
| 15 |
-
# ββ Pipeline imports (TkAgg call inside module is
|
| 16 |
from graph_cut_segmentation import (
|
| 17 |
iterative_graph_cut,
|
| 18 |
refine_segmentation,
|
|
@@ -23,6 +29,9 @@ from graph_cut_segmentation import (
|
|
| 23 |
generate_auto_annotations,
|
| 24 |
)
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 28 |
# Helpers
|
|
|
|
| 5 |
import warnings
|
| 6 |
warnings.filterwarnings("ignore")
|
| 7 |
|
| 8 |
+
# Monkey-patch matplotlib.use so that graph_cut_segmentation.py's
|
| 9 |
+
# module-level `matplotlib.use("TkAgg")` call becomes a no-op on import.
|
| 10 |
+
# We cannot modify that file, so we intercept here instead.
|
| 11 |
+
_real_use = matplotlib.use
|
| 12 |
+
matplotlib.use = lambda *a, **kw: None
|
| 13 |
+
|
| 14 |
# ββ Standard imports βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 15 |
import gradio as gr
|
| 16 |
import numpy as np
|
|
|
|
| 18 |
import io
|
| 19 |
from PIL import Image
|
| 20 |
|
| 21 |
+
# ββ Pipeline imports (TkAgg call inside module is now intercepted) βββββ
|
| 22 |
from graph_cut_segmentation import (
|
| 23 |
iterative_graph_cut,
|
| 24 |
refine_segmentation,
|
|
|
|
| 29 |
generate_auto_annotations,
|
| 30 |
)
|
| 31 |
|
| 32 |
+
# Restore real matplotlib.use now that the problematic import is done
|
| 33 |
+
matplotlib.use = _real_use
|
| 34 |
+
|
| 35 |
|
| 36 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 37 |
# Helpers
|