Spaces:
Build error
Build error
msIntui commited on
Commit ·
589b914
1
Parent(s): 3f1e63e
Fix import order and logging initialization
Browse files- detectors.py +7 -38
detectors.py
CHANGED
|
@@ -31,53 +31,22 @@ from ultralytics import YOLO
|
|
| 31 |
from storage import StorageInterface
|
| 32 |
from base import BaseDetector
|
| 33 |
from config import SymbolConfig, TagConfig, LineConfig, PointConfig, JunctionConfig
|
| 34 |
-
from line_detectors import OpenCVLineDetector,
|
| 35 |
-
from detection_schema import (
|
| 36 |
-
BBox, Coordinates, Point, Line, Symbol, Tag,
|
| 37 |
-
SymbolType, LineStyle, ConnectionType, JunctionType, Junction
|
| 38 |
-
)
|
| 39 |
-
|
| 40 |
-
# Base imports that shouldn't fail
|
| 41 |
-
from storage import StorageInterface
|
| 42 |
-
from base import BaseDetector
|
| 43 |
-
from config import SymbolConfig, TagConfig, LineConfig, PointConfig, JunctionConfig
|
| 44 |
|
| 45 |
-
#
|
| 46 |
-
DEEPLSD_AVAILABLE = False
|
| 47 |
try:
|
| 48 |
-
from
|
| 49 |
-
|
| 50 |
except ImportError as e:
|
| 51 |
-
logger.warning(f"DeepLSD import failed: {str(e)}.
|
| 52 |
|
| 53 |
-
#
|
| 54 |
-
from ultralytics import YOLO
|
| 55 |
from detection_schema import (
|
| 56 |
BBox, Coordinates, Point, Line, Symbol, Tag,
|
| 57 |
SymbolType, LineStyle, ConnectionType, JunctionType, Junction
|
| 58 |
)
|
| 59 |
|
| 60 |
-
#
|
| 61 |
-
from detection_schema import (
|
| 62 |
-
BBox,
|
| 63 |
-
Coordinates,
|
| 64 |
-
Point,
|
| 65 |
-
Line,
|
| 66 |
-
Symbol,
|
| 67 |
-
Tag,
|
| 68 |
-
SymbolType,
|
| 69 |
-
LineStyle,
|
| 70 |
-
ConnectionType,
|
| 71 |
-
JunctionType,
|
| 72 |
-
Junction
|
| 73 |
-
)
|
| 74 |
-
|
| 75 |
-
# Skeletonization and label processing for junction detection
|
| 76 |
-
from skimage.morphology import skeletonize
|
| 77 |
-
from skimage.measure import label
|
| 78 |
-
|
| 79 |
-
# At the top with other imports
|
| 80 |
-
from line_detectors import OpenCVLineDetector, DeepLSDDetector, DEEPLSD_AVAILABLE
|
| 81 |
|
| 82 |
class Detector(ABC):
|
| 83 |
"""Base class for all detectors"""
|
|
|
|
| 31 |
from storage import StorageInterface
|
| 32 |
from base import BaseDetector
|
| 33 |
from config import SymbolConfig, TagConfig, LineConfig, PointConfig, JunctionConfig
|
| 34 |
+
from line_detectors import OpenCVLineDetector, DEEPLSD_AVAILABLE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
# Try to import DeepLSD, but don't fail if not available
|
|
|
|
| 37 |
try:
|
| 38 |
+
from line_detectors import DeepLSDDetector
|
| 39 |
+
logger.info("Successfully imported DeepLSD")
|
| 40 |
except ImportError as e:
|
| 41 |
+
logger.warning(f"DeepLSD import failed: {str(e)}. Will use OpenCV fallback.")
|
| 42 |
|
| 43 |
+
# Detection schema imports
|
|
|
|
| 44 |
from detection_schema import (
|
| 45 |
BBox, Coordinates, Point, Line, Symbol, Tag,
|
| 46 |
SymbolType, LineStyle, ConnectionType, JunctionType, Junction
|
| 47 |
)
|
| 48 |
|
| 49 |
+
# Rest of the classes...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
class Detector(ABC):
|
| 52 |
"""Base class for all detectors"""
|