Spaces:
Running
Running
github-actions Claude Sonnet 4.6 commited on
Commit ·
4cd4e97
1
Parent(s): ff8d97c
add --debug flag to keep only panel images by default
Browse filesWithout --debug, all intermediate processing images are cleaned up after
extraction, leaving only _panel_ files in the output folder. Pass --debug
to retain all intermediate images for troubleshooting.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
.gitignore
CHANGED
|
@@ -221,4 +221,6 @@ yolo_output/
|
|
| 221 |
comic_panel_extractor/best.pt
|
| 222 |
*.pt
|
| 223 |
comic_panel_extractor/filtered_comic.yaml
|
| 224 |
-
comic_panel_extractor/filtered_dataset
|
|
|
|
|
|
|
|
|
| 221 |
comic_panel_extractor/best.pt
|
| 222 |
*.pt
|
| 223 |
comic_panel_extractor/filtered_comic.yaml
|
| 224 |
+
comic_panel_extractor/filtered_dataset
|
| 225 |
+
config.json
|
| 226 |
+
temp/
|
comic_panel_extractor/cli.py
CHANGED
|
@@ -42,6 +42,11 @@ Examples:
|
|
| 42 |
"--config",
|
| 43 |
help="Path to JSON configuration file"
|
| 44 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
return parser
|
| 47 |
|
|
@@ -51,6 +56,7 @@ Examples:
|
|
| 51 |
parsed_args = self.parser.parse_args(args)
|
| 52 |
# Load configuration
|
| 53 |
config = self._load_config(parsed_args)
|
|
|
|
| 54 |
ComicPanelExtractor(config).extract_panels_from_comic()
|
| 55 |
except Exception as e:
|
| 56 |
print(f"❌ Error: {e}", file=sys.stderr)
|
|
|
|
| 42 |
"--config",
|
| 43 |
help="Path to JSON configuration file"
|
| 44 |
)
|
| 45 |
+
parser.add_argument(
|
| 46 |
+
"--debug",
|
| 47 |
+
action="store_true",
|
| 48 |
+
help="Keep all intermediate processing images in the output folder"
|
| 49 |
+
)
|
| 50 |
|
| 51 |
return parser
|
| 52 |
|
|
|
|
| 56 |
parsed_args = self.parser.parse_args(args)
|
| 57 |
# Load configuration
|
| 58 |
config = self._load_config(parsed_args)
|
| 59 |
+
config.debug = parsed_args.debug
|
| 60 |
ComicPanelExtractor(config).extract_panels_from_comic()
|
| 61 |
except Exception as e:
|
| 62 |
print(f"❌ Error: {e}", file=sys.stderr)
|
comic_panel_extractor/config.py
CHANGED
|
@@ -50,6 +50,9 @@ class Config:
|
|
| 50 |
# BorderPanelExtractor
|
| 51 |
panel_filename_pattern: str = r"panel_\d+_\((\d+), (\d+), (\d+), (\d+)\)\.jpg"
|
| 52 |
|
|
|
|
|
|
|
|
|
|
| 53 |
# Constants
|
| 54 |
SUPPORTED_EXTENSIONS: tuple = ('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG')
|
| 55 |
|
|
|
|
| 50 |
# BorderPanelExtractor
|
| 51 |
panel_filename_pattern: str = r"panel_\d+_\((\d+), (\d+), (\d+), (\d+)\)\.jpg"
|
| 52 |
|
| 53 |
+
# Debug mode
|
| 54 |
+
debug: bool = False
|
| 55 |
+
|
| 56 |
# Constants
|
| 57 |
SUPPORTED_EXTENSIONS: tuple = ('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG')
|
| 58 |
|
comic_panel_extractor/llm_panel_extractor.py
CHANGED
|
@@ -245,6 +245,12 @@ def extract_panel_via_llm(input_image_path, config=None, reset=True):
|
|
| 245 |
accumulated_detected_boxes.extend(remain_boxes)
|
| 246 |
|
| 247 |
all_path = [file for file in os.listdir(extractor_config.output_folder) if "_panel_" in file]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
print(f"Processing complete. Final result saved to: {extractor_config.output_folder}")
|
| 249 |
print(f"Total panels detected: {len(all_path)}")
|
| 250 |
return all_path, accumulated_detected_boxes, all_processed_boxes
|
|
|
|
| 245 |
accumulated_detected_boxes.extend(remain_boxes)
|
| 246 |
|
| 247 |
all_path = [file for file in os.listdir(extractor_config.output_folder) if "_panel_" in file]
|
| 248 |
+
|
| 249 |
+
if not extractor_config.debug:
|
| 250 |
+
for file in os.listdir(extractor_config.output_folder):
|
| 251 |
+
if "_panel_" not in file:
|
| 252 |
+
os.remove(os.path.join(extractor_config.output_folder, file))
|
| 253 |
+
|
| 254 |
print(f"Processing complete. Final result saved to: {extractor_config.output_folder}")
|
| 255 |
print(f"Total panels detected: {len(all_path)}")
|
| 256 |
return all_path, accumulated_detected_boxes, all_processed_boxes
|