Spaces:
Running
Running
new ch
Browse files- .gitignore +3 -1
- comic_panel_extractor/train.py +10 -10
- comic_panel_extractor/yolo_manager.py +4 -2
.gitignore
CHANGED
|
@@ -218,4 +218,6 @@ test*.jpg
|
|
| 218 |
yolo_output/
|
| 219 |
*:Zone.Identifier
|
| 220 |
comic_panel_extractor/best.pt
|
| 221 |
-
*.pt
|
|
|
|
|
|
|
|
|
| 218 |
yolo_output/
|
| 219 |
*:Zone.Identifier
|
| 220 |
comic_panel_extractor/best.pt
|
| 221 |
+
*.pt
|
| 222 |
+
comic_panel_extractor/filtered_comic.yaml
|
| 223 |
+
comic_panel_extractor/filtered_dataset
|
comic_panel_extractor/train.py
CHANGED
|
@@ -8,13 +8,13 @@ import os
|
|
| 8 |
from pathlib import Path
|
| 9 |
import shutil
|
| 10 |
|
| 11 |
-
def create_filtered_dataset(original_dataset_path,
|
| 12 |
"""
|
| 13 |
Create a filtered dataset with only images that have non-empty labels
|
| 14 |
"""
|
| 15 |
-
shutil.rmtree(
|
| 16 |
-
original_path = Path(
|
| 17 |
-
output_path = Path(
|
| 18 |
|
| 19 |
# Create output directory structure
|
| 20 |
output_images = output_path / "images"
|
|
@@ -67,11 +67,11 @@ def create_filtered_dataset(original_dataset_path, output_base_path):
|
|
| 67 |
|
| 68 |
return filtered_counts
|
| 69 |
|
| 70 |
-
def create_filtered_yaml(
|
| 71 |
"""
|
| 72 |
Create the YAML file for the filtered dataset
|
| 73 |
"""
|
| 74 |
-
output_path = Path(
|
| 75 |
yaml_path = f'{Config.current_path}/filtered_comic.yaml'
|
| 76 |
|
| 77 |
# Create YAML structure
|
|
@@ -131,17 +131,17 @@ def main():
|
|
| 131 |
if __name__ == "__main__":# Configuration
|
| 132 |
# Configuration
|
| 133 |
original_dataset_path = "/home/jebineinstein/git/comic-panel-extractor/comic_panel_extractor/dataset"
|
| 134 |
-
|
| 135 |
|
| 136 |
print("π Starting dataset filtering...")
|
| 137 |
print(f"π Source: {original_dataset_path}")
|
| 138 |
-
print(f"π Output: {
|
| 139 |
|
| 140 |
# Create filtered dataset
|
| 141 |
-
filtered_counts = create_filtered_dataset(original_dataset_path,
|
| 142 |
|
| 143 |
# Create YAML file
|
| 144 |
-
yaml_path = create_filtered_yaml(
|
| 145 |
|
| 146 |
# Summary
|
| 147 |
total_filtered = sum(filtered_counts.values())
|
|
|
|
| 8 |
from pathlib import Path
|
| 9 |
import shutil
|
| 10 |
|
| 11 |
+
def create_filtered_dataset(original_dataset_path, output_filtered_dataset_path):
|
| 12 |
"""
|
| 13 |
Create a filtered dataset with only images that have non-empty labels
|
| 14 |
"""
|
| 15 |
+
shutil.rmtree(output_filtered_dataset_path, ignore_errors=True)
|
| 16 |
+
original_path = Path(original_dataset_path)
|
| 17 |
+
output_path = Path(output_filtered_dataset_path)
|
| 18 |
|
| 19 |
# Create output directory structure
|
| 20 |
output_images = output_path / "images"
|
|
|
|
| 67 |
|
| 68 |
return filtered_counts
|
| 69 |
|
| 70 |
+
def create_filtered_yaml(output_filtered_dataset_path, filtered_counts):
|
| 71 |
"""
|
| 72 |
Create the YAML file for the filtered dataset
|
| 73 |
"""
|
| 74 |
+
output_path = Path(output_filtered_dataset_path)
|
| 75 |
yaml_path = f'{Config.current_path}/filtered_comic.yaml'
|
| 76 |
|
| 77 |
# Create YAML structure
|
|
|
|
| 131 |
if __name__ == "__main__":# Configuration
|
| 132 |
# Configuration
|
| 133 |
original_dataset_path = "/home/jebineinstein/git/comic-panel-extractor/comic_panel_extractor/dataset"
|
| 134 |
+
output_filtered_dataset_path = "/home/jebineinstein/git/comic-panel-extractor/comic_panel_extractor/filtered_dataset"
|
| 135 |
|
| 136 |
print("π Starting dataset filtering...")
|
| 137 |
print(f"π Source: {original_dataset_path}")
|
| 138 |
+
print(f"π Output: {output_filtered_dataset_path}")
|
| 139 |
|
| 140 |
# Create filtered dataset
|
| 141 |
+
filtered_counts = create_filtered_dataset(original_dataset_path, output_filtered_dataset_path)
|
| 142 |
|
| 143 |
# Create YAML file
|
| 144 |
+
yaml_path = create_filtered_yaml(output_filtered_dataset_path, filtered_counts)
|
| 145 |
|
| 146 |
# Summary
|
| 147 |
total_filtered = sum(filtered_counts.values())
|
comic_panel_extractor/yolo_manager.py
CHANGED
|
@@ -68,7 +68,7 @@ class YOLOManager:
|
|
| 68 |
print(f"π¦ Loading model from: {weights_path}")
|
| 69 |
self.model = YOLO(weights_path)
|
| 70 |
else:
|
| 71 |
-
print("β¨ Loading pretrained model '
|
| 72 |
self.model = YOLO(f"{Config.current_path}/yolo12s.pt")
|
| 73 |
return self.model
|
| 74 |
|
|
@@ -111,7 +111,9 @@ class YOLOManager:
|
|
| 111 |
'cache': True,
|
| 112 |
'project': f'{Config.current_path}/runs/detect',
|
| 113 |
'exist_ok': True,
|
| 114 |
-
'
|
|
|
|
|
|
|
| 115 |
}
|
| 116 |
|
| 117 |
# Update with custom parameters
|
|
|
|
| 68 |
print(f"π¦ Loading model from: {weights_path}")
|
| 69 |
self.model = YOLO(weights_path)
|
| 70 |
else:
|
| 71 |
+
print("β¨ Loading pretrained model 'yolo12s.pt'")
|
| 72 |
self.model = YOLO(f"{Config.current_path}/yolo12s.pt")
|
| 73 |
return self.model
|
| 74 |
|
|
|
|
| 111 |
'cache': True,
|
| 112 |
'project': f'{Config.current_path}/runs/detect',
|
| 113 |
'exist_ok': True,
|
| 114 |
+
'pose': False,
|
| 115 |
+
'resume': resume_flag,
|
| 116 |
+
'amp': False, # π« Disable AMP to prevent yolo11n.pt download
|
| 117 |
}
|
| 118 |
|
| 119 |
# Update with custom parameters
|