Spaces:
Running
Running
new ch
Browse files
comic_panel_extractor/extractor_server.py
CHANGED
|
@@ -56,7 +56,7 @@ async def convert_comic(file: UploadFile = File(...)):
|
|
| 56 |
specific_output_folder = f'{output_folder}/{file_id}'
|
| 57 |
|
| 58 |
shutil.rmtree(specific_output_folder, ignore_errors=True)
|
| 59 |
-
Path(specific_output_folder).mkdir(exist_ok=True)
|
| 60 |
file_path = f'{specific_output_folder}/{file.filename}'
|
| 61 |
|
| 62 |
# Save uploaded file
|
|
|
|
| 56 |
specific_output_folder = f'{output_folder}/{file_id}'
|
| 57 |
|
| 58 |
shutil.rmtree(specific_output_folder, ignore_errors=True)
|
| 59 |
+
Path(specific_output_folder).mkdir(parents=True, exist_ok=True)
|
| 60 |
file_path = f'{specific_output_folder}/{file.filename}'
|
| 61 |
|
| 62 |
# Save uploaded file
|
comic_panel_extractor/llm_panel_extractor.py
CHANGED
|
@@ -17,7 +17,7 @@ class LLMPanelExtractor:
|
|
| 17 |
|
| 18 |
# Check if YOLO model exists; if not, download it to the specified path
|
| 19 |
yolo_base_model_path = f'{self.config.yolo_base_model_path}_best.pt'
|
| 20 |
-
yolo_base_model_path = f'{self.config.yolo_trained_model_path}'
|
| 21 |
if not os.path.exists(yolo_base_model_path):
|
| 22 |
url = "https://huggingface.co/mosesb/best-comic-panel-detection/resolve/main/best.pt"
|
| 23 |
print(f"Downloading YOLO model to {yolo_base_model_path}...")
|
|
|
|
| 17 |
|
| 18 |
# Check if YOLO model exists; if not, download it to the specified path
|
| 19 |
yolo_base_model_path = f'{self.config.yolo_base_model_path}_best.pt'
|
| 20 |
+
# yolo_base_model_path = f'{self.config.yolo_trained_model_path}'
|
| 21 |
if not os.path.exists(yolo_base_model_path):
|
| 22 |
url = "https://huggingface.co/mosesb/best-comic-panel-detection/resolve/main/best.pt"
|
| 23 |
print(f"Downloading YOLO model to {yolo_base_model_path}...")
|
comic_panel_extractor/static/annotator.html
CHANGED
|
@@ -522,6 +522,15 @@
|
|
| 522 |
πΈ Comic Panel Annotator
|
| 523 |
</div>
|
| 524 |
<div class="nav-actions">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
<button class="btn btn-ghost btn-sm" id="prevBtn" disabled>
|
| 526 |
β Prev
|
| 527 |
</button>
|
|
@@ -545,9 +554,9 @@
|
|
| 545 |
<div class="sidebar">
|
| 546 |
<!-- Image Selection -->
|
| 547 |
<div class="sidebar-section">
|
| 548 |
-
<div class="section-title">Image Selection</div>
|
| 549 |
|
| 550 |
-
<div class="image-nav">
|
| 551 |
<!-- <button class="btn btn-ghost btn-sm" id="prevBtn" disabled>
|
| 552 |
β Prev
|
| 553 |
</button> -->
|
|
@@ -555,15 +564,15 @@
|
|
| 555 |
No image
|
| 556 |
</div> -->
|
| 557 |
|
| 558 |
-
<div class="form-field">
|
| 559 |
<select class="form-select" id="imageSelect">
|
| 560 |
<option value="">Choose an image...</option>
|
| 561 |
</select>
|
| 562 |
-
</div>
|
| 563 |
<!-- <button class="btn btn-ghost btn-sm" id="nextBtn" disabled>
|
| 564 |
Next β
|
| 565 |
</button> -->
|
| 566 |
-
</div>
|
| 567 |
<!-- Annotation Mode -->
|
| 568 |
<div class="sidebar-section">
|
| 569 |
<div class="section-title">Annotation Mode</div>
|
|
@@ -573,14 +582,14 @@
|
|
| 573 |
<option value="bbox">Bounding Box (YOLO)</option>
|
| 574 |
</select>
|
| 575 |
</div>
|
| 576 |
-
<div class="form-field">
|
| 577 |
<label class="form-label">Class ID</label>
|
| 578 |
<input type="number" class="form-input" id="classId" value="0" min="0" max="100">
|
| 579 |
</div>
|
| 580 |
</div>
|
| 581 |
|
| 582 |
|
| 583 |
-
<div class="file-upload">
|
| 584 |
<input type="file" id="uploadFile" accept="image/*">
|
| 585 |
<label for="uploadFile" class="file-upload-label">
|
| 586 |
π€ Drop or click to upload
|
|
@@ -589,7 +598,7 @@
|
|
| 589 |
</div>
|
| 590 |
|
| 591 |
<!-- Progress -->
|
| 592 |
-
<div class="sidebar-section">
|
| 593 |
<div class="progress-section">
|
| 594 |
<h3 style="margin-bottom: 12px; font-size: 16px;">Progress</h3>
|
| 595 |
<div class="progress-stat">
|
|
@@ -600,7 +609,7 @@
|
|
| 600 |
<div class="progress-fill" id="progressFill" style="width: 0%"></div>
|
| 601 |
</div>
|
| 602 |
</div>
|
| 603 |
-
</div>
|
| 604 |
|
| 605 |
<!-- Current Image Info -->
|
| 606 |
<div class="sidebar-section" id="currentImageInfo" style="display: none;">
|
|
@@ -661,7 +670,7 @@
|
|
| 661 |
<div id="polygonEditControls" style="display: none;">
|
| 662 |
<div class="form-field" style="margin-bottom: 8px;">
|
| 663 |
<label class="form-label">Points (<span id="pointCount">0</span>)</label>
|
| 664 |
-
<div id="pointsList" style="max-height:
|
| 665 |
border: 1px solid #e2e8f0; border-radius: 4px; padding: 8px;">
|
| 666 |
<!-- Points will be populated here -->
|
| 667 |
</div>
|
|
@@ -688,7 +697,7 @@
|
|
| 688 |
|
| 689 |
|
| 690 |
<!-- Quick Actions -->
|
| 691 |
-
<div class="sidebar-section">
|
| 692 |
<div class="section-title">Actions</div>
|
| 693 |
<button class="btn btn-primary btn-block" id="reloadBtn">
|
| 694 |
π Reload Annotations
|
|
@@ -699,7 +708,7 @@
|
|
| 699 |
<button class="btn btn-secondary btn-block" id="downloadBtn" style="display: none; margin-top: 8px;">
|
| 700 |
π₯ Download
|
| 701 |
</button>
|
| 702 |
-
</div
|
| 703 |
|
| 704 |
<!-- Quick Help -->
|
| 705 |
<div class="sidebar-section">
|
|
@@ -727,9 +736,15 @@
|
|
| 727 |
<!-- Canvas Area -->
|
| 728 |
<div class="canvas-area">
|
| 729 |
<div class="canvas-toolbar">
|
| 730 |
-
<span id="file_name" style="font-size: 13px; color: #4a5568;">
|
| 731 |
Click and drag to create annotation annotations β’ Select annotations to move or resize
|
| 732 |
-
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 733 |
</div>
|
| 734 |
|
| 735 |
<div class="canvas-container">
|
|
@@ -906,7 +921,7 @@
|
|
| 906 |
document.getElementById('totalImages').textContent = this.images.length;
|
| 907 |
document.getElementById('annotatedImages').textContent = annotated;
|
| 908 |
const progress = this.images.length > 0 ? (annotated / this.images.length) * 100 : 0;
|
| 909 |
-
document.getElementById('progressFill').style.width = progress + '%';
|
| 910 |
|
| 911 |
this.updateNavigationButtons();
|
| 912 |
|
|
@@ -935,7 +950,7 @@
|
|
| 935 |
this.currentImageIndex--;
|
| 936 |
const imageName = this.images[this.currentImageIndex].name;
|
| 937 |
document.getElementById('imageSelect').value = imageName;
|
| 938 |
-
document.getElementById('file_name').innerText = imageName;
|
| 939 |
this.loadImage(imageName);
|
| 940 |
}
|
| 941 |
}
|
|
@@ -945,7 +960,7 @@
|
|
| 945 |
this.currentImageIndex++;
|
| 946 |
const imageName = this.images[this.currentImageIndex].name;
|
| 947 |
document.getElementById('imageSelect').value = imageName;
|
| 948 |
-
document.getElementById('file_name').innerText = imageName;
|
| 949 |
this.loadImage(imageName);
|
| 950 |
}
|
| 951 |
}
|
|
|
|
| 522 |
πΈ Comic Panel Annotator
|
| 523 |
</div>
|
| 524 |
<div class="nav-actions">
|
| 525 |
+
<button class="btn btn-primary btn-sm" id="detectBtn" style="display: none;">
|
| 526 |
+
π Detect
|
| 527 |
+
</button>
|
| 528 |
+
<button class="btn btn-secondary btn-sm" id="downloadBtn" style="display: none;">
|
| 529 |
+
π₯ Download
|
| 530 |
+
</button>
|
| 531 |
+
<button class="btn btn-primary btn-sm" id="reloadBtn">
|
| 532 |
+
π Reload
|
| 533 |
+
</button>
|
| 534 |
<button class="btn btn-ghost btn-sm" id="prevBtn" disabled>
|
| 535 |
β Prev
|
| 536 |
</button>
|
|
|
|
| 554 |
<div class="sidebar">
|
| 555 |
<!-- Image Selection -->
|
| 556 |
<div class="sidebar-section">
|
| 557 |
+
<div class="section-title" style="display: none;">Image Selection</div>
|
| 558 |
|
| 559 |
+
<!-- <div class="image-nav"> -->
|
| 560 |
<!-- <button class="btn btn-ghost btn-sm" id="prevBtn" disabled>
|
| 561 |
β Prev
|
| 562 |
</button> -->
|
|
|
|
| 564 |
No image
|
| 565 |
</div> -->
|
| 566 |
|
| 567 |
+
<!-- <div class="form-field">
|
| 568 |
<select class="form-select" id="imageSelect">
|
| 569 |
<option value="">Choose an image...</option>
|
| 570 |
</select>
|
| 571 |
+
</div> -->
|
| 572 |
<!-- <button class="btn btn-ghost btn-sm" id="nextBtn" disabled>
|
| 573 |
Next β
|
| 574 |
</button> -->
|
| 575 |
+
<!-- </div> -->
|
| 576 |
<!-- Annotation Mode -->
|
| 577 |
<div class="sidebar-section">
|
| 578 |
<div class="section-title">Annotation Mode</div>
|
|
|
|
| 582 |
<option value="bbox">Bounding Box (YOLO)</option>
|
| 583 |
</select>
|
| 584 |
</div>
|
| 585 |
+
<div class="form-field" style="display: none;">
|
| 586 |
<label class="form-label">Class ID</label>
|
| 587 |
<input type="number" class="form-input" id="classId" value="0" min="0" max="100">
|
| 588 |
</div>
|
| 589 |
</div>
|
| 590 |
|
| 591 |
|
| 592 |
+
<div class="file-upload" style="display: none;">
|
| 593 |
<input type="file" id="uploadFile" accept="image/*">
|
| 594 |
<label for="uploadFile" class="file-upload-label">
|
| 595 |
π€ Drop or click to upload
|
|
|
|
| 598 |
</div>
|
| 599 |
|
| 600 |
<!-- Progress -->
|
| 601 |
+
<!-- <div class="sidebar-section">
|
| 602 |
<div class="progress-section">
|
| 603 |
<h3 style="margin-bottom: 12px; font-size: 16px;">Progress</h3>
|
| 604 |
<div class="progress-stat">
|
|
|
|
| 609 |
<div class="progress-fill" id="progressFill" style="width: 0%"></div>
|
| 610 |
</div>
|
| 611 |
</div>
|
| 612 |
+
</div> -->
|
| 613 |
|
| 614 |
<!-- Current Image Info -->
|
| 615 |
<div class="sidebar-section" id="currentImageInfo" style="display: none;">
|
|
|
|
| 670 |
<div id="polygonEditControls" style="display: none;">
|
| 671 |
<div class="form-field" style="margin-bottom: 8px;">
|
| 672 |
<label class="form-label">Points (<span id="pointCount">0</span>)</label>
|
| 673 |
+
<div id="pointsList" style="max-height: 400px; overflow-y: auto;
|
| 674 |
border: 1px solid #e2e8f0; border-radius: 4px; padding: 8px;">
|
| 675 |
<!-- Points will be populated here -->
|
| 676 |
</div>
|
|
|
|
| 697 |
|
| 698 |
|
| 699 |
<!-- Quick Actions -->
|
| 700 |
+
<!-- <div class="sidebar-section">
|
| 701 |
<div class="section-title">Actions</div>
|
| 702 |
<button class="btn btn-primary btn-block" id="reloadBtn">
|
| 703 |
π Reload Annotations
|
|
|
|
| 708 |
<button class="btn btn-secondary btn-block" id="downloadBtn" style="display: none; margin-top: 8px;">
|
| 709 |
π₯ Download
|
| 710 |
</button>
|
| 711 |
+
</div>-->
|
| 712 |
|
| 713 |
<!-- Quick Help -->
|
| 714 |
<div class="sidebar-section">
|
|
|
|
| 736 |
<!-- Canvas Area -->
|
| 737 |
<div class="canvas-area">
|
| 738 |
<div class="canvas-toolbar">
|
| 739 |
+
<!-- <span id="file_name" style="font-size: 13px; color: #4a5568;">
|
| 740 |
Click and drag to create annotation annotations β’ Select annotations to move or resize
|
| 741 |
+
</span> -->
|
| 742 |
+
<div class="form-field">
|
| 743 |
+
<select class="form-select" id="imageSelect">
|
| 744 |
+
<option value="">Choose an image...</option>
|
| 745 |
+
</select>
|
| 746 |
+
</div>
|
| 747 |
+
<span id="annotatedImages">0</span>/<span id="totalImages">0</span>
|
| 748 |
</div>
|
| 749 |
|
| 750 |
<div class="canvas-container">
|
|
|
|
| 921 |
document.getElementById('totalImages').textContent = this.images.length;
|
| 922 |
document.getElementById('annotatedImages').textContent = annotated;
|
| 923 |
const progress = this.images.length > 0 ? (annotated / this.images.length) * 100 : 0;
|
| 924 |
+
// document.getElementById('progressFill').style.width = progress + '%';
|
| 925 |
|
| 926 |
this.updateNavigationButtons();
|
| 927 |
|
|
|
|
| 950 |
this.currentImageIndex--;
|
| 951 |
const imageName = this.images[this.currentImageIndex].name;
|
| 952 |
document.getElementById('imageSelect').value = imageName;
|
| 953 |
+
// document.getElementById('file_name').innerText = imageName;
|
| 954 |
this.loadImage(imageName);
|
| 955 |
}
|
| 956 |
}
|
|
|
|
| 960 |
this.currentImageIndex++;
|
| 961 |
const imageName = this.images[this.currentImageIndex].name;
|
| 962 |
document.getElementById('imageSelect').value = imageName;
|
| 963 |
+
// document.getElementById('file_name').innerText = imageName;
|
| 964 |
this.loadImage(imageName);
|
| 965 |
}
|
| 966 |
}
|
comic_panel_extractor/static/index.html
CHANGED
|
@@ -346,7 +346,7 @@
|
|
| 346 |
<button class="btn" onclick="document.getElementById('file-input').click()">
|
| 347 |
Choose File
|
| 348 |
</button>
|
| 349 |
-
<button class="btn btn-clear" onclick="clearPanels()">
|
| 350 |
Clear All Panels
|
| 351 |
</button>
|
| 352 |
</div>
|
|
|
|
| 346 |
<button class="btn" onclick="document.getElementById('file-input').click()">
|
| 347 |
Choose File
|
| 348 |
</button>
|
| 349 |
+
<button class="btn btn-clear" onclick="clearPanels()" style="display: none;">
|
| 350 |
Clear All Panels
|
| 351 |
</button>
|
| 352 |
</div>
|