msIntui commited on
Commit
c2516d1
·
1 Parent(s): 66da89f

Fix import order and logger initialization

Browse files
Files changed (2) hide show
  1. detectors.py +20 -12
  2. requirements.txt +1 -1
detectors.py CHANGED
@@ -10,28 +10,36 @@ import json
10
  import uuid
11
  from pathlib import Path
12
  from abc import ABC, abstractmethod
13
- from ultralytics import YOLO
14
  from PIL import Image
15
  import matplotlib.pyplot as plt
16
- from storage import StorageInterface
17
- import logging
18
 
19
- # Configure logging first
 
 
 
 
20
  logger = logging.getLogger(__name__)
21
 
22
- # Then try imports that might fail
 
 
 
 
 
 
23
  try:
24
  from deeplsd.models.deeplsd_inference import DeepLSD
25
  DEEPLSD_AVAILABLE = True
26
  except ImportError as e:
27
- logger.warning(f"DeepLSD import failed: {e}. Falling back to basic line detection.")
28
- DEEPLSD_AVAILABLE = False
29
 
30
- # Base classes and utilities
31
- from base import BaseDetector
32
- from detection_schema import DetectionContext
33
- from utils import DebugHandler
34
- from config import SymbolConfig, TagConfig, LineConfig, PointConfig, JunctionConfig
 
35
 
36
  # Detection schema: dataclasses for different objects
37
  from detection_schema import (
 
10
  import uuid
11
  from pathlib import Path
12
  from abc import ABC, abstractmethod
13
+ import logging
14
  from PIL import Image
15
  import matplotlib.pyplot as plt
 
 
16
 
17
+ # Configure logging first, before any other imports
18
+ logging.basicConfig(
19
+ level=logging.INFO,
20
+ format='%(asctime)s - %(levelname)s - %(message)s'
21
+ )
22
  logger = logging.getLogger(__name__)
23
 
24
+ # Base imports that shouldn't fail
25
+ from storage import StorageInterface
26
+ from base import BaseDetector
27
+ from config import SymbolConfig, TagConfig, LineConfig, PointConfig, JunctionConfig
28
+
29
+ # Optional imports with fallbacks
30
+ DEEPLSD_AVAILABLE = False
31
  try:
32
  from deeplsd.models.deeplsd_inference import DeepLSD
33
  DEEPLSD_AVAILABLE = True
34
  except ImportError as e:
35
+ logger.warning(f"DeepLSD import failed: {str(e)}. Falling back to basic line detection.")
 
36
 
37
+ # Rest of imports that should be available
38
+ from ultralytics import YOLO
39
+ from detection_schema import (
40
+ BBox, Coordinates, Point, Line, Symbol, Tag,
41
+ SymbolType, LineStyle, ConnectionType, JunctionType, Junction
42
+ )
43
 
44
  # Detection schema: dataclasses for different objects
45
  from detection_schema import (
requirements.txt CHANGED
@@ -17,7 +17,7 @@ torchvision>=0.15.0
17
  ultralytics>=8.0.0
18
  git+https://github.com/cvg/DeepLSD.git # Install DeepLSD from GitHub
19
  omegaconf>=2.3.0 # Required by DeepLSD
20
- pytlsd # Required by DeepLSD
21
 
22
  # Graph Processing
23
  networkx>=2.6.0
 
17
  ultralytics>=8.0.0
18
  git+https://github.com/cvg/DeepLSD.git # Install DeepLSD from GitHub
19
  omegaconf>=2.3.0 # Required by DeepLSD
20
+ git+https://github.com/rpautrat/pytlsd.git # Required by DeepLSD
21
 
22
  # Graph Processing
23
  networkx>=2.6.0