453 lines
17 KiB
HTML
453 lines
17 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<meta
|
|
name="description"
|
|
content="AI Caricature Face Tool - Detect faces and rotation points"
|
|
/>
|
|
<title>AI Caricature Face Tool</title>
|
|
|
|
<!-- Font Awesome -->
|
|
<link
|
|
rel="stylesheet"
|
|
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
|
|
/>
|
|
|
|
<!-- Google Fonts -->
|
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
<link
|
|
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap"
|
|
rel="stylesheet"
|
|
/>
|
|
|
|
<!-- Styles -->
|
|
<link rel="stylesheet" href="/css/styles.css" />
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container">
|
|
<!-- Header -->
|
|
<header>
|
|
<div
|
|
style="
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
"
|
|
>
|
|
<div>
|
|
<h1><i class="fas fa-grin-stars"></i> AI Caricature Face Tool</h1>
|
|
<p class="subtitle">Detect faces & rotation points for caricature generation</p>
|
|
</div>
|
|
<button
|
|
class="btn btn-secondary"
|
|
onclick="toggleFormatModal(true)"
|
|
style="padding: 10px 15px; min-width: auto"
|
|
>
|
|
<i class="fas fa-cog"></i> Format
|
|
</button>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Tabs -->
|
|
<div class="tabs">
|
|
<button class="tab active" onclick="switchTab('single')" id="single-tab">
|
|
<i class="fas fa-image"></i> Single Image
|
|
</button>
|
|
<button class="tab" onclick="switchTab('batch')" id="batch-tab">
|
|
<i class="fas fa-images"></i> Batch Processing
|
|
</button>
|
|
<button class="tab" onclick="switchTab('results')" id="results-tab">
|
|
<i class="fas fa-list-alt"></i> Results
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Single Image Tab -->
|
|
<div id="single-content" class="tab-content active">
|
|
<div class="main-content">
|
|
<div class="left-panel">
|
|
<!-- Upload Area -->
|
|
<div
|
|
class="upload-area"
|
|
id="uploadArea"
|
|
onclick="document.getElementById('fileInput').click()"
|
|
>
|
|
<i class="fas fa-cloud-upload-alt"></i>
|
|
<h3>Drag & Drop or Click to Upload Image</h3>
|
|
<p>Supports PNG, JPG, JPEG, WEBP, BMP</p>
|
|
<input
|
|
type="file"
|
|
id="fileInput"
|
|
class="file-input"
|
|
accept="image/*"
|
|
/>
|
|
</div>
|
|
|
|
<!-- Image Display -->
|
|
<div class="image-container" id="imageContainer">
|
|
<canvas id="imageCanvas"></canvas>
|
|
<div class="empty-state" id="emptyState">
|
|
<i class="fas fa-image"></i>
|
|
<p>No image selected</p>
|
|
<p>Upload an image with faces to detect</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Controls -->
|
|
<div class="controls">
|
|
<button
|
|
class="btn btn-primary"
|
|
onclick="analyzeImage()"
|
|
id="analyzeBtn"
|
|
>
|
|
<i class="fas fa-search"></i>
|
|
<span>Detect Faces</span>
|
|
</button>
|
|
<button
|
|
class="btn btn-secondary"
|
|
onclick="toggleCreateMode()"
|
|
id="addBoxBtn"
|
|
title="Manually draw a bounding box"
|
|
>
|
|
<i class="fas fa-plus-square"></i>
|
|
<span>Add Box</span>
|
|
</button>
|
|
<button
|
|
class="btn btn-success"
|
|
onclick="saveCoordinates()"
|
|
id="saveBtn"
|
|
disabled
|
|
>
|
|
<i class="fas fa-save"></i>
|
|
<span>Save Coordinates</span>
|
|
</button>
|
|
<button class="btn btn-warning" onclick="clearImage()">
|
|
<i class="fas fa-trash"></i>
|
|
<span>Clear</span>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Format Info -->
|
|
<div class="format-info collapsed" onclick="toggleFormatInfo()">
|
|
<h4><i class="fas fa-info-circle"></i> Output Format</h4>
|
|
<p>Coordinate: <span class="format-code">x1:y1,x2:y2;...</span></p>
|
|
<p>Rotation: <span class="format-code">x:y;...</span></p>
|
|
<p style="margin-top: 8px; font-size: 12px; opacity: 0.8">
|
|
(Click to clean/expand)
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Right Panel - Coordinates List -->
|
|
<div class="right-panel">
|
|
<h3><i class="fas fa-map-marker-alt"></i> Detected Faces</h3>
|
|
<div id="coordinatesList">
|
|
<div class="empty-state">
|
|
<i class="fas fa-shapes"></i>
|
|
<p>No faces detected yet</p>
|
|
<p>Analyze an image to see coordinates</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Batch Processing Tab -->
|
|
<div id="batch-content" class="tab-content">
|
|
<div class="main-content batch-content-layout">
|
|
<div class="left-panel">
|
|
<!-- Batch Section -->
|
|
<div class="batch-section">
|
|
<h3><i class="fas fa-folder-tree"></i> Batch Processing</h3>
|
|
<p>Process all images in a folder (including subfolders)</p>
|
|
|
|
<div style="margin-top: 20px">
|
|
<input
|
|
type="file"
|
|
id="folderInput"
|
|
class="file-input"
|
|
webkitdirectory
|
|
directory
|
|
multiple
|
|
/>
|
|
<button
|
|
class="btn btn-primary"
|
|
onclick="document.getElementById('folderInput').click()"
|
|
style="width: 100%"
|
|
>
|
|
<i class="fas fa-folder-open"></i>
|
|
<span>Select Folder</span>
|
|
</button>
|
|
|
|
<div class="detection-limits" style="margin-top: 15px; padding: 15px; background: #fff; border: 1px solid #dee2e6; border-radius: 8px;">
|
|
<h4 style="margin: 0 0 10px 0; font-size: 14px; color: #495057;">Detection Limits</h4>
|
|
<div style="display: flex; gap: 10px;">
|
|
<div style="flex: 1;">
|
|
<label style="font-size: 12px; display: block; margin-bottom: 5px;" title="Minimum faces required. If fewer are found, image is flagged for manual review.">Min Faces</label>
|
|
<input type="number" id="minFaces" class="form-input" value="0" min="0" style="padding: 5px; font-size: 12px;">
|
|
</div>
|
|
<div style="flex: 1;">
|
|
<label style="font-size: 12px; display: block; margin-bottom: 5px;" title="Maximum faces to return (keeps most prominent). 0 = no limit.">Max Faces</label>
|
|
<input type="number" id="maxFaces" class="form-input" value="0" min="0" style="padding: 5px; font-size: 12px;">
|
|
</div>
|
|
</div>
|
|
<div style="margin-top: 10px;">
|
|
<label style="font-size: 12px; display: flex; justify-content: space-between; margin-bottom: 5px;">
|
|
<span title="Lower = catches more faces (may have false positives). Higher = stricter detection.">Confidence Threshold</span>
|
|
<span id="confThresholdVal" style="color: #667eea; font-weight: 600;">0.15</span>
|
|
</label>
|
|
<input type="range" id="confThreshold" min="0.01" max="0.80" step="0.01" value="0.15"
|
|
style="width: 100%; cursor: pointer;"
|
|
oninput="document.getElementById('confThresholdVal').textContent = parseFloat(this.value).toFixed(2)">
|
|
<div style="display: flex; justify-content: space-between; font-size: 10px; color: #adb5bd; margin-top: 2px;">
|
|
<span>0.01 (sensitive)</span><span>0.80 (strict)</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div
|
|
id="batchStatus"
|
|
style="
|
|
margin-top: 15px;
|
|
padding: 15px;
|
|
background: #f8f9fa;
|
|
border-radius: 8px;
|
|
text-align: center;
|
|
color: #6c757d;
|
|
"
|
|
>
|
|
No folder selected
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Progress Container -->
|
|
<div
|
|
class="progress-container"
|
|
id="progressContainer"
|
|
style="display: none"
|
|
>
|
|
<div
|
|
style="
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-bottom: 10px;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
"
|
|
>
|
|
<span id="progressText">Processing...</span>
|
|
<span id="progressPercent">0%</span>
|
|
</div>
|
|
<div class="progress-bar">
|
|
<div class="progress-fill" id="progressFill"></div>
|
|
</div>
|
|
<div
|
|
id="batchStats"
|
|
style="
|
|
margin-top: 10px;
|
|
color: #6c757d;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
"
|
|
>
|
|
Files: 0 | Processed: 0
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Batch Controls -->
|
|
<div class="controls" style="margin-top: 25px">
|
|
<button
|
|
class="btn btn-primary"
|
|
onclick="startBatchProcessing()"
|
|
id="batchStartBtn"
|
|
>
|
|
<i class="fas fa-play"></i>
|
|
<span>Start Processing</span>
|
|
</button>
|
|
<button
|
|
class="btn btn-success"
|
|
onclick="saveAllCoordinates()"
|
|
id="saveAllBtn"
|
|
disabled
|
|
>
|
|
<i class="fas fa-save"></i>
|
|
<span>Save All Coordinates</span>
|
|
</button>
|
|
<button class="btn btn-warning" onclick="clearBatch()">
|
|
<i class="fas fa-times"></i>
|
|
<span>Clear Results</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Batch Results -->
|
|
<div class="batch-results" id="batchResults" style="display: none">
|
|
<h4 style="margin-bottom: 15px; color: #495057; font-weight: 700">
|
|
<i class="fas fa-list"></i> Processing Results:
|
|
</h4>
|
|
|
|
<div class="batch-slider-wrapper">
|
|
<button class="slider-btn prev" onclick="scrollBatch('left')">
|
|
<i class="fas fa-chevron-left"></i>
|
|
</button>
|
|
|
|
<div id="batchResultsList" class="batch-list">
|
|
<!-- Results will appear here -->
|
|
</div>
|
|
|
|
<button class="slider-btn next" onclick="scrollBatch('right')">
|
|
<i class="fas fa-chevron-right"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Results Tab -->
|
|
<div id="results-content" class="tab-content">
|
|
<div class="main-content">
|
|
<div class="left-panel">
|
|
<!-- Results Section -->
|
|
<div class="results-section">
|
|
<h3><i class="fas fa-file-code"></i> Coordinates File</h3>
|
|
<p style="color: #6c757d; margin-top: 10px">
|
|
All saved coordinates are stored in a single file
|
|
</p>
|
|
|
|
<div class="results-content" id="resultsContent">
|
|
No coordinates saved yet
|
|
</div>
|
|
|
|
<!-- Results Controls -->
|
|
<div class="controls" style="margin-top: 20px">
|
|
<button class="btn btn-primary" onclick="loadResults()">
|
|
<i class="fas fa-sync"></i>
|
|
<span>Refresh</span>
|
|
</button>
|
|
<button class="btn btn-warning" onclick="clearResults()">
|
|
<i class="fas fa-trash"></i>
|
|
<span>Clear All</span>
|
|
</button>
|
|
<div class="split-btn-group" style="display: flex; gap: 8px">
|
|
<button
|
|
class="btn btn-secondary"
|
|
onclick="downloadResults('text')"
|
|
>
|
|
<i class="fas fa-file-alt"></i> TXT
|
|
</button>
|
|
<button
|
|
class="btn btn-secondary"
|
|
onclick="downloadResults('json')"
|
|
>
|
|
<i class="fas fa-file-code"></i> JSON
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Right Panel - Recent Entries -->
|
|
<div class="right-panel">
|
|
<h3><i class="fas fa-history"></i> Recent Entries</h3>
|
|
<div id="recentEntries" style="margin-top: 15px">
|
|
<p style="color: #adb5bd; text-align: center; padding: 40px 0">
|
|
No recent entries
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Loading Spinner -->
|
|
<div class="loading" id="loading">
|
|
<div class="spinner"></div>
|
|
</div>
|
|
|
|
<!-- Format Settings Modal -->
|
|
<div id="formatModal" class="modal">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h3><i class="fas fa-cog"></i> Coordinate Format Settings</h3>
|
|
<span class="close-modal" onclick="toggleFormatModal(false)"
|
|
>×</span
|
|
>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="setting-group">
|
|
<label>Coordinate Format:</label>
|
|
<input type="text" id="coordFormat" class="form-input" placeholder="e.g. {tl_x}:{tl_y},{br_x}:{br_y}" value="{tl_x}:{tl_y},{br_x}:{br_y}">
|
|
<p class="help-text">Use placeholders: {tl_x}, {tl_y}, {tr_x}, {tr_y}, {br_x}, {br_y}, {bl_x}, {bl_y}, {width}, {height}, {angle}</p>
|
|
</div>
|
|
|
|
<div class="setting-group">
|
|
<label>Rotation Point Format:</label>
|
|
<input type="text" id="rotFormat" class="form-input" placeholder="e.g. {rot_x}:{rot_y}" value="{rot_x}:{rot_y}">
|
|
<p class="help-text">Use placeholders: {rot_x}, {rot_y}, {angle}</p>
|
|
</div>
|
|
|
|
<div class="setting-group">
|
|
<label>Separator (between multiple faces):</label>
|
|
<input type="text" id="sepFrame" value=";" class="form-input" style="width: 50px; text-align: center;">
|
|
</div>
|
|
|
|
<div class="preview-box">
|
|
<label>Preview:</label>
|
|
<div id="formatPreview" class="code-preview">
|
|
x1,y1:x2,y2:x3,y3:x4,y4
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn btn-secondary" onclick="toggleFormatModal(false)">
|
|
Cancel
|
|
</button>
|
|
<button class="btn btn-primary" onclick="saveFormatSettings()">
|
|
Apply Settings
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Batch Detail Modal -->
|
|
<div id="batchDetailModal" class="modal">
|
|
<div class="modal-content detail-modal-content">
|
|
<div class="modal-header">
|
|
<h3><i class="fas fa-edit"></i> Edit Detected Faces</h3>
|
|
<span class="close-modal" onclick="closeBatchDetail()">×</span>
|
|
</div>
|
|
<div class="modal-body detail-modal-body">
|
|
<div class="detail-canvas-container">
|
|
<canvas id="detailCanvas"></canvas>
|
|
</div>
|
|
<div class="detail-sidebar">
|
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
|
|
<h4 style="color: #495057; margin: 0;">Detected Faces</h4>
|
|
<button class="btn btn-secondary" onclick="toggleDetailCreateMode()" id="detailAddBoxBtn" style="padding: 5px 10px; font-size: 12px; min-width: auto;">
|
|
<i class="fas fa-plus-square"></i> Add
|
|
</button>
|
|
</div>
|
|
<div id="detailList" class="detail-list">
|
|
<!-- Face items will be injected here -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn btn-primary" onclick="closeBatchDetail()">
|
|
Done
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Message Notification -->
|
|
<div class="message" id="message"></div>
|
|
|
|
<!-- JavaScript -->
|
|
<script src="/js/main.js"></script>
|
|
</body>
|
|
</html>
|