Update utilities.py
Browse files- utilities.py +2 -1
utilities.py
CHANGED
|
@@ -8,7 +8,6 @@
|
|
| 8 |
import cv2
|
| 9 |
import numpy as np
|
| 10 |
import torch
|
| 11 |
-
import requests
|
| 12 |
from PIL import Image, ImageDraw
|
| 13 |
import logging
|
| 14 |
import time
|
|
@@ -119,6 +118,7 @@ def segment_person_hq(image, predictor):
|
|
| 119 |
x1, y1 = w//4, h//6
|
| 120 |
x2, y2 = 3*w//4, 5*h//6
|
| 121 |
fallback_mask[y1:y2, x1:x2] = 255
|
|
|
|
| 122 |
return fallback_mask
|
| 123 |
|
| 124 |
def refine_mask_hq(image, mask, matanyone_processor):
|
|
@@ -143,6 +143,7 @@ def refine_mask_hq(image, mask, matanyone_processor):
|
|
| 143 |
pass
|
| 144 |
|
| 145 |
# Fallback to OpenCV refinement
|
|
|
|
| 146 |
return enhance_mask_opencv(image, mask)
|
| 147 |
|
| 148 |
except Exception as e:
|
|
|
|
| 8 |
import cv2
|
| 9 |
import numpy as np
|
| 10 |
import torch
|
|
|
|
| 11 |
from PIL import Image, ImageDraw
|
| 12 |
import logging
|
| 13 |
import time
|
|
|
|
| 118 |
x1, y1 = w//4, h//6
|
| 119 |
x2, y2 = 3*w//4, 5*h//6
|
| 120 |
fallback_mask[y1:y2, x1:x2] = 255
|
| 121 |
+
logger.warning("Using fallback mask due to segmentation error")
|
| 122 |
return fallback_mask
|
| 123 |
|
| 124 |
def refine_mask_hq(image, mask, matanyone_processor):
|
|
|
|
| 143 |
pass
|
| 144 |
|
| 145 |
# Fallback to OpenCV refinement
|
| 146 |
+
logger.warning("Using OpenCV fallback for mask refinement")
|
| 147 |
return enhance_mask_opencv(image, mask)
|
| 148 |
|
| 149 |
except Exception as e:
|