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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fr">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>🩷Colara🩷</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: Arial, sans-serif;
|
| 10 |
+
background-color: #f0f2f5;
|
| 11 |
+
display: flex;
|
| 12 |
+
flex-direction: column;
|
| 13 |
+
align-items: center;
|
| 14 |
+
padding: 40px;
|
| 15 |
+
text-align: center;
|
| 16 |
+
}
|
| 17 |
+
.container {
|
| 18 |
+
width: 100%;
|
| 19 |
+
max-width: 800px;
|
| 20 |
+
background-color: #fff;
|
| 21 |
+
border-radius: 10px;
|
| 22 |
+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
| 23 |
+
padding: 30px;
|
| 24 |
+
}
|
| 25 |
+
h1 {
|
| 26 |
+
color: #333;
|
| 27 |
+
}
|
| 28 |
+
.file-upload-section {
|
| 29 |
+
margin: 20px 0;
|
| 30 |
+
}
|
| 31 |
+
.file-upload-section label {
|
| 32 |
+
background-color: #007bff;
|
| 33 |
+
color: #fff;
|
| 34 |
+
padding: 12px 25px;
|
| 35 |
+
border-radius: 5px;
|
| 36 |
+
cursor: pointer;
|
| 37 |
+
font-size: 1rem;
|
| 38 |
+
transition: background-color 0.3s;
|
| 39 |
+
}
|
| 40 |
+
.file-upload-section label:hover {
|
| 41 |
+
background-color: #0056b3;
|
| 42 |
+
}
|
| 43 |
+
#upload-input {
|
| 44 |
+
display: none;
|
| 45 |
+
}
|
| 46 |
+
.image-display {
|
| 47 |
+
display: flex;
|
| 48 |
+
justify-content: space-around;
|
| 49 |
+
flex-wrap: wrap;
|
| 50 |
+
margin-top: 20px;
|
| 51 |
+
gap: 20px;
|
| 52 |
+
}
|
| 53 |
+
.image-box {
|
| 54 |
+
display: flex;
|
| 55 |
+
flex-direction: column;
|
| 56 |
+
align-items: center;
|
| 57 |
+
}
|
| 58 |
+
.image-box canvas, .image-box img {
|
| 59 |
+
max-width: 350px;
|
| 60 |
+
border: 2px dashed #ccc;
|
| 61 |
+
border-radius: 5px;
|
| 62 |
+
}
|
| 63 |
+
.image-box h3 {
|
| 64 |
+
margin-top: 10px;
|
| 65 |
+
color: #555;
|
| 66 |
+
}
|
| 67 |
+
</style>
|
| 68 |
+
</head>
|
| 69 |
+
<body>
|
| 70 |
+
|
| 71 |
+
<div class="container">
|
| 72 |
+
<h1>🩷Colara🩷</h1>
|
| 73 |
+
<p>L'IA qui change les couleurs de vos images.</p>
|
| 74 |
+
|
| 75 |
+
<div class="file-upload-section">
|
| 76 |
+
<label for="upload-input">Télécharger une image</label>
|
| 77 |
+
<input type="file" id="upload-input" accept="image/*">
|
| 78 |
+
</div>
|
| 79 |
+
|
| 80 |
+
<div class="image-display">
|
| 81 |
+
<div class="image-box">
|
| 82 |
+
<h3>Original</h3>
|
| 83 |
+
<canvas id="original-canvas"></canvas>
|
| 84 |
+
</div>
|
| 85 |
+
<div class="image-box">
|
| 86 |
+
<h3>Colara</h3>
|
| 87 |
+
<canvas id="colara-canvas"></canvas>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
<p id="status-message"></p>
|
| 91 |
+
</div>
|
| 92 |
+
|
| 93 |
+
<script type="module">
|
| 94 |
+
const modelName = 'Clemylia/Colora-model';
|
| 95 |
+
const originalCanvas = document.getElementById('original-canvas');
|
| 96 |
+
const colaraCanvas = document.getElementById('colara-canvas');
|
| 97 |
+
const originalCtx = originalCanvas.getContext('2d');
|
| 98 |
+
const colaraCtx = colaraCanvas.getContext('2d');
|
| 99 |
+
const uploadInput = document.getElementById('upload-input');
|
| 100 |
+
const statusMessage = document.getElementById('status-message');
|
| 101 |
+
|
| 102 |
+
let colaraModel = null;
|
| 103 |
+
let isModelReady = false;
|
| 104 |
+
|
| 105 |
+
async function initializeModel() {
|
| 106 |
+
statusMessage.textContent = 'Chargement du modèle...';
|
| 107 |
+
try {
|
| 108 |
+
const response = await fetch(`https://huggingface.co/${modelName}/raw/main/colora.js`);
|
| 109 |
+
if (!response.ok) {
|
| 110 |
+
throw new Error(`Erreur de téléchargement : ${response.statusText}`);
|
| 111 |
+
}
|
| 112 |
+
const scriptText = await response.text();
|
| 113 |
+
|
| 114 |
+
const scriptBlob = new Blob([scriptText], { type: 'application/javascript' });
|
| 115 |
+
const scriptUrl = URL.createObjectURL(scriptBlob);
|
| 116 |
+
|
| 117 |
+
const module = await import(scriptUrl);
|
| 118 |
+
|
| 119 |
+
colaraModel = new module.default();
|
| 120 |
+
isModelReady = true;
|
| 121 |
+
statusMessage.textContent = 'Modèle Colara prêt ! Téléchargez une image.';
|
| 122 |
+
} catch (error) {
|
| 123 |
+
statusMessage.textContent = `Erreur de chargement : ${error.message}`;
|
| 124 |
+
console.error(error);
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
uploadInput.addEventListener('change', async (event) => {
|
| 129 |
+
if (!isModelReady) {
|
| 130 |
+
alert("Le modèle n'est pas prêt. Veuillez patienter.");
|
| 131 |
+
return;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
const file = event.target.files[0];
|
| 135 |
+
if (file) {
|
| 136 |
+
statusMessage.textContent = 'Analyse de l\'image en cours...';
|
| 137 |
+
|
| 138 |
+
const reader = new FileReader();
|
| 139 |
+
reader.onload = async (e) => {
|
| 140 |
+
const img = new Image();
|
| 141 |
+
img.onload = async () => {
|
| 142 |
+
// Afficher l'image originale
|
| 143 |
+
originalCanvas.width = img.width;
|
| 144 |
+
originalCanvas.height = img.height;
|
| 145 |
+
originalCtx.drawImage(img, 0, 0);
|
| 146 |
+
|
| 147 |
+
// Appeler le modèle pour générer l'image modifiée
|
| 148 |
+
const processedResult = await colaraModel.generate(file);
|
| 149 |
+
|
| 150 |
+
// Afficher l'image générée
|
| 151 |
+
const processedImgUrl = URL.createObjectURL(processedResult.image);
|
| 152 |
+
const processedImg = new Image();
|
| 153 |
+
processedImg.onload = () => {
|
| 154 |
+
colaraCanvas.width = processedImg.width;
|
| 155 |
+
colaraCanvas.height = processedImg.height;
|
| 156 |
+
colaraCtx.drawImage(processedImg, 0, 0);
|
| 157 |
+
statusMessage.textContent = 'Image traitée !';
|
| 158 |
+
};
|
| 159 |
+
processedImg.src = processedImgUrl;
|
| 160 |
+
};
|
| 161 |
+
img.src = e.target.result;
|
| 162 |
+
};
|
| 163 |
+
reader.readAsDataURL(file);
|
| 164 |
+
}
|
| 165 |
+
});
|
| 166 |
+
|
| 167 |
+
initializeModel();
|
| 168 |
+
</script>
|
| 169 |
+
</body>
|
| 170 |
+
</html>
|