Spaces:
Running
Running
constant
Browse files
comic_panel_extractor/config.py
CHANGED
|
@@ -21,9 +21,18 @@ class Config:
|
|
| 21 |
|
| 22 |
# Read from TOML config
|
| 23 |
EPOCH: int = int(config_data.get("EPOCH", 200))
|
|
|
|
|
|
|
|
|
|
| 24 |
YOLO_BASE_MODEL_NAME: str = config_data.get("YOLO_BASE_MODEL_NAME", "yolo11s-seg")
|
| 25 |
YOLO_MODEL_NAME: str = config_data.get("YOLO_MODEL_NAME", f"comic_panel_{YOLO_BASE_MODEL_NAME}")
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
# Derived paths
|
| 29 |
yolo_base_model_path: str = f"{current_path}/{YOLO_BASE_MODEL_NAME}.pt"
|
|
@@ -46,7 +55,6 @@ class Config:
|
|
| 46 |
panel_filename_pattern: str = r"panel_\d+_\((\d+), (\d+), (\d+), (\d+)\)\.jpg"
|
| 47 |
|
| 48 |
# Static constants
|
| 49 |
-
DEFAULT_IMAGE_SIZE: int = 640
|
| 50 |
SUPPORTED_EXTENSIONS: list = ('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG')
|
| 51 |
|
| 52 |
def get_text_cood_file_path(config: Config):
|
|
|
|
| 21 |
|
| 22 |
# Read from TOML config
|
| 23 |
EPOCH: int = int(config_data.get("EPOCH", 200))
|
| 24 |
+
DEFAULT_IMAGE_SIZE: int = int(config_data.get("DEFAULT_IMAGE_SIZE", 640))
|
| 25 |
+
BATCH: int = int(config_data.get("BATCH", 10))
|
| 26 |
+
RESUME_TRAIN: bool = str(config_data.get("RESUME_TRAIN", "True")).lower() in ("1", "true", "yes")
|
| 27 |
YOLO_BASE_MODEL_NAME: str = config_data.get("YOLO_BASE_MODEL_NAME", "yolo11s-seg")
|
| 28 |
YOLO_MODEL_NAME: str = config_data.get("YOLO_MODEL_NAME", f"comic_panel_{YOLO_BASE_MODEL_NAME}")
|
| 29 |
+
image_path_from_config = config_data.get("IMAGE_SOURCE_PATH", "")
|
| 30 |
+
# Ensure absolute path
|
| 31 |
+
IMAGE_SOURCE_PATH: str = (
|
| 32 |
+
image_path_from_config
|
| 33 |
+
if os.path.isabs(image_path_from_config)
|
| 34 |
+
else os.path.join(CURRENT_PATH, image_path_from_config)
|
| 35 |
+
)
|
| 36 |
|
| 37 |
# Derived paths
|
| 38 |
yolo_base_model_path: str = f"{current_path}/{YOLO_BASE_MODEL_NAME}.pt"
|
|
|
|
| 55 |
panel_filename_pattern: str = r"panel_\d+_\((\d+), (\d+), (\d+), (\d+)\)\.jpg"
|
| 56 |
|
| 57 |
# Static constants
|
|
|
|
| 58 |
SUPPORTED_EXTENSIONS: list = ('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG')
|
| 59 |
|
| 60 |
def get_text_cood_file_path(config: Config):
|
comic_panel_extractor/config.toml
CHANGED
|
@@ -1,4 +1,7 @@
|
|
| 1 |
EPOCH=200
|
|
|
|
|
|
|
|
|
|
| 2 |
YOLO_BASE_MODEL_NAME="yolo11s-seg"
|
| 3 |
YOLO_MODEL_NAME="comic_panel_yolo11s-seg"
|
| 4 |
-
IMAGE_SOURCE_PATH="
|
|
|
|
| 1 |
EPOCH=200
|
| 2 |
+
DEFAULT_IMAGE_SIZE=640
|
| 3 |
+
BATCH=10
|
| 4 |
+
RESUME_TRAIN="true"
|
| 5 |
YOLO_BASE_MODEL_NAME="yolo11s-seg"
|
| 6 |
YOLO_MODEL_NAME="comic_panel_yolo11s-seg"
|
| 7 |
+
IMAGE_SOURCE_PATH="comic-panel-extractor/comic_panel_extractor/images"
|
comic_panel_extractor/static/annotator.html
CHANGED
|
@@ -683,9 +683,6 @@
|
|
| 683 |
π€ Drop or click to upload
|
| 684 |
</label>
|
| 685 |
</div>
|
| 686 |
-
<button class="btn btn-primary btn-sm trainBtn" id="trainBtn">
|
| 687 |
-
Train
|
| 688 |
-
</button>
|
| 689 |
</div>
|
| 690 |
|
| 691 |
<!-- Progress -->
|
|
@@ -788,9 +785,18 @@
|
|
| 788 |
|
| 789 |
|
| 790 |
<!-- Quick Actions -->
|
| 791 |
-
|
| 792 |
<div class="section-title">Actions</div>
|
| 793 |
-
<button class="btn btn-primary btn-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 794 |
π Reload Annotations
|
| 795 |
</button>
|
| 796 |
<button class="btn btn-primary btn-block" id="detectBtn" style="display: none; margin-top: 8px;">
|
|
@@ -798,8 +804,8 @@
|
|
| 798 |
</button>
|
| 799 |
<button class="btn btn-secondary btn-block" id="downloadBtn" style="display: none; margin-top: 8px;">
|
| 800 |
π₯ Download
|
| 801 |
-
</button>
|
| 802 |
-
</div
|
| 803 |
|
| 804 |
<!-- Quick Help -->
|
| 805 |
<div class="sidebar-section">
|
|
|
|
| 683 |
π€ Drop or click to upload
|
| 684 |
</label>
|
| 685 |
</div>
|
|
|
|
|
|
|
|
|
|
| 686 |
</div>
|
| 687 |
|
| 688 |
<!-- Progress -->
|
|
|
|
| 785 |
|
| 786 |
|
| 787 |
<!-- Quick Actions -->
|
| 788 |
+
<div class="sidebar-section">
|
| 789 |
<div class="section-title">Actions</div>
|
| 790 |
+
<button class="btn btn-primary btn-sm trainBtn" id="trainBtn">
|
| 791 |
+
Train
|
| 792 |
+
</button>
|
| 793 |
+
<button class="btn btn-primary btn-sm trainBtn" id="deployModalBtn">
|
| 794 |
+
Deploy Model
|
| 795 |
+
</button>
|
| 796 |
+
<button class="btn btn-primary btn-sm trainBtn" id="resetModalBtn">
|
| 797 |
+
Reset Model
|
| 798 |
+
</button>
|
| 799 |
+
<!-- <button class="btn btn-primary btn-block" id="reloadBtn">
|
| 800 |
π Reload Annotations
|
| 801 |
</button>
|
| 802 |
<button class="btn btn-primary btn-block" id="detectBtn" style="display: none; margin-top: 8px;">
|
|
|
|
| 804 |
</button>
|
| 805 |
<button class="btn btn-secondary btn-block" id="downloadBtn" style="display: none; margin-top: 8px;">
|
| 806 |
π₯ Download
|
| 807 |
+
</button> -->
|
| 808 |
+
</div>
|
| 809 |
|
| 810 |
<!-- Quick Help -->
|
| 811 |
<div class="sidebar-section">
|
comic_panel_extractor/yolo_manager.py
CHANGED
|
@@ -79,7 +79,7 @@ class YOLOManager:
|
|
| 79 |
data_yaml_path: str,
|
| 80 |
run_name: Optional[str] = None,
|
| 81 |
device: int = 0,
|
| 82 |
-
resume: bool =
|
| 83 |
**kwargs) -> YOLO:
|
| 84 |
"""
|
| 85 |
Train YOLO model with given parameters.
|
|
@@ -108,7 +108,7 @@ class YOLOManager:
|
|
| 108 |
'data': data_yaml_path,
|
| 109 |
'imgsz': Config.DEFAULT_IMAGE_SIZE,
|
| 110 |
'epochs': Config.EPOCH,
|
| 111 |
-
'batch':
|
| 112 |
'name': run_name,
|
| 113 |
'device': device,
|
| 114 |
'cache': True,
|
|
|
|
| 79 |
data_yaml_path: str,
|
| 80 |
run_name: Optional[str] = None,
|
| 81 |
device: int = 0,
|
| 82 |
+
resume: bool = Config.RESUME_TRAIN,
|
| 83 |
**kwargs) -> YOLO:
|
| 84 |
"""
|
| 85 |
Train YOLO model with given parameters.
|
|
|
|
| 108 |
'data': data_yaml_path,
|
| 109 |
'imgsz': Config.DEFAULT_IMAGE_SIZE,
|
| 110 |
'epochs': Config.EPOCH,
|
| 111 |
+
'batch': Config.BATCH,
|
| 112 |
'name': run_name,
|
| 113 |
'device': device,
|
| 114 |
'cache': True,
|