Update stamp_processing/remover.py
Browse files
stamp_processing/remover.py
CHANGED
@@ -7,7 +7,7 @@ import numpy.typing as npt
|
|
7 |
from .detector import StampDetector
|
8 |
from .module.unet import *
|
9 |
from .preprocess import create_batch
|
10 |
-
from .utils import REMOVER_WEIGHT_ID, check_image_shape, download_weight
|
11 |
|
12 |
|
13 |
class StampRemover:
|
@@ -23,16 +23,16 @@ class StampRemover:
|
|
23 |
os.makedirs("tmp/", exist_ok=True)
|
24 |
removal_weight = os.path.join("tmp", "stamp_remover.pkl")
|
25 |
|
26 |
-
|
27 |
download_weight(REMOVER_WEIGHT_ID, output=removal_weight)
|
28 |
-
|
29 |
|
30 |
try:
|
31 |
self.remover = UnetInference(removal_weight) # type: ignore
|
32 |
except Exception as e:
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
"Please make sure you provide the correct path to the weight"
|
37 |
"or mannually download the weight at"
|
38 |
f"https://drive.google.com/file/d/{REMOVER_WEIGHT_ID}/view?usp=sharing"
|
|
|
7 |
from .detector import StampDetector
|
8 |
from .module.unet import *
|
9 |
from .preprocess import create_batch
|
10 |
+
from .utils import REMOVER_WEIGHT_ID, check_image_shape, download_weight
|
11 |
|
12 |
|
13 |
class StampRemover:
|
|
|
23 |
os.makedirs("tmp/", exist_ok=True)
|
24 |
removal_weight = os.path.join("tmp", "stamp_remover.pkl")
|
25 |
|
26 |
+
print("Downloading stamp remover weight from google drive")
|
27 |
download_weight(REMOVER_WEIGHT_ID, output=removal_weight)
|
28 |
+
print(f"Finished downloading. Weight is saved at {removal_weight}")
|
29 |
|
30 |
try:
|
31 |
self.remover = UnetInference(removal_weight) # type: ignore
|
32 |
except Exception as e:
|
33 |
+
print(e)
|
34 |
+
print("There is something wrong when loading remover weight")
|
35 |
+
print(
|
36 |
"Please make sure you provide the correct path to the weight"
|
37 |
"or mannually download the weight at"
|
38 |
f"https://drive.google.com/file/d/{REMOVER_WEIGHT_ID}/view?usp=sharing"
|