Spaces:
Running
on
T4
Running
on
T4
Update segment_image.py
Browse files- segment_image.py +3 -2
segment_image.py
CHANGED
@@ -3,6 +3,7 @@ from shapely.geometry import Polygon
|
|
3 |
from ultralyticsplus import YOLO
|
4 |
from PIL import Image
|
5 |
import numpy as np
|
|
|
6 |
|
7 |
from reading_order import OrderPolygons
|
8 |
|
@@ -58,7 +59,7 @@ class SegmentImage:
|
|
58 |
"""Function for initializing the line detection model."""
|
59 |
try:
|
60 |
# Load the trained line detection model
|
61 |
-
line_model = YOLO(self.line_model_path,
|
62 |
return line_model
|
63 |
except Exception as e:
|
64 |
print('Failed to load the line detection model: %s' % e)
|
@@ -67,7 +68,7 @@ class SegmentImage:
|
|
67 |
"""Function for initializing the region detection model."""
|
68 |
try:
|
69 |
# Load the trained line detection model
|
70 |
-
region_model = YOLO(self.region_model_path,
|
71 |
return region_model
|
72 |
except Exception as e:
|
73 |
print('Failed to load the region detection model: %s' % e)
|
|
|
3 |
from ultralyticsplus import YOLO
|
4 |
from PIL import Image
|
5 |
import numpy as np
|
6 |
+
import os
|
7 |
|
8 |
from reading_order import OrderPolygons
|
9 |
|
|
|
59 |
"""Function for initializing the line detection model."""
|
60 |
try:
|
61 |
# Load the trained line detection model
|
62 |
+
line_model = YOLO(self.line_model_path, hf_token=os.getenv("HF_TOKEN"))
|
63 |
return line_model
|
64 |
except Exception as e:
|
65 |
print('Failed to load the line detection model: %s' % e)
|
|
|
68 |
"""Function for initializing the region detection model."""
|
69 |
try:
|
70 |
# Load the trained line detection model
|
71 |
+
region_model = YOLO(self.region_model_path, hf_token=os.getenv("HF_TOKEN"))
|
72 |
return region_model
|
73 |
except Exception as e:
|
74 |
print('Failed to load the region detection model: %s' % e)
|