Spaces:
Running
Running
rem prnit
Browse files
comic_panel_extractor/image_processor.py
CHANGED
|
@@ -62,8 +62,6 @@ class ImageProcessor:
|
|
| 62 |
black_pixels = np.sum(binary == 0)
|
| 63 |
white_pixels = np.sum(binary == 255)
|
| 64 |
|
| 65 |
-
print(f"Black pixels: {black_pixels}, White pixels: {white_pixels}")
|
| 66 |
-
|
| 67 |
# If black dominates, invert
|
| 68 |
if black_pixels > white_pixels:
|
| 69 |
print("π Inverting image because black > white")
|
|
|
|
| 62 |
black_pixels = np.sum(binary == 0)
|
| 63 |
white_pixels = np.sum(binary == 255)
|
| 64 |
|
|
|
|
|
|
|
| 65 |
# If black dominates, invert
|
| 66 |
if black_pixels > white_pixels:
|
| 67 |
print("π Inverting image because black > white")
|
comic_panel_extractor/panel_extractor.py
CHANGED
|
@@ -35,7 +35,7 @@ class PanelExtractor:
|
|
| 35 |
def __init__(self, config: Config):
|
| 36 |
self.config = config
|
| 37 |
|
| 38 |
-
def extract_panels(self, dilated_path: str, row_thresh: int = 20, col_thresh: int = 20, min_width_ratio: float = 0.1, min_height_ratio: float = 0.1, min_area_ratio: float = 0.
|
| 39 |
"""Extract comic panels using black percentage scan."""
|
| 40 |
dilated = cv2.imread(dilated_path, cv2.IMREAD_GRAYSCALE)
|
| 41 |
original = cv2.imread(self.config.input_path)
|
|
|
|
| 35 |
def __init__(self, config: Config):
|
| 36 |
self.config = config
|
| 37 |
|
| 38 |
+
def extract_panels(self, dilated_path: str, row_thresh: int = 20, col_thresh: int = 20, min_width_ratio: float = 0.1, min_height_ratio: float = 0.1, min_area_ratio: float = 0.01) -> Tuple[List[np.ndarray], List[PanelData]]:
|
| 39 |
"""Extract comic panels using black percentage scan."""
|
| 40 |
dilated = cv2.imread(dilated_path, cv2.IMREAD_GRAYSCALE)
|
| 41 |
original = cv2.imread(self.config.input_path)
|
comic_panel_extractor/server.py
CHANGED
|
@@ -22,8 +22,6 @@ static_folder = "./static"
|
|
| 22 |
output_folder = os.path.abspath(os.path.realpath(os.path.join(os.path.dirname(__file__), f'./{base_output_folder}')))
|
| 23 |
static_folder = os.path.abspath(os.path.realpath(os.path.join(os.path.dirname(__file__), static_folder)))
|
| 24 |
|
| 25 |
-
print(output_folder)
|
| 26 |
-
print(static_folder)
|
| 27 |
# Create directories for uploads and outputs
|
| 28 |
os.makedirs(output_folder, exist_ok=True)
|
| 29 |
os.makedirs(static_folder, exist_ok=True)
|
|
|
|
| 22 |
output_folder = os.path.abspath(os.path.realpath(os.path.join(os.path.dirname(__file__), f'./{base_output_folder}')))
|
| 23 |
static_folder = os.path.abspath(os.path.realpath(os.path.join(os.path.dirname(__file__), static_folder)))
|
| 24 |
|
|
|
|
|
|
|
| 25 |
# Create directories for uploads and outputs
|
| 26 |
os.makedirs(output_folder, exist_ok=True)
|
| 27 |
os.makedirs(static_folder, exist_ok=True)
|