Spaces:
Running
Running
Update index.html
Browse files- index.html +128 -36
index.html
CHANGED
|
@@ -1,52 +1,144 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
<head>
|
| 4 |
-
<meta charset="
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
<style>
|
| 7 |
body {
|
| 8 |
-
font-family:
|
| 9 |
-
max-width:
|
| 10 |
-
margin:
|
| 11 |
-
padding:
|
| 12 |
}
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
padding: 20px;
|
| 18 |
-
margin-top: 20px;
|
| 19 |
}
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
| 28 |
</style>
|
| 29 |
</head>
|
| 30 |
|
| 31 |
<body>
|
| 32 |
-
<h1>Movie Review Sentiment Analysis</h1>
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
|
| 40 |
-
<h2>Model</h2>
|
| 41 |
|
| 42 |
-
|
| 43 |
-
The model is hosted on Hugging Face Hub.
|
| 44 |
-
</p>
|
| 45 |
|
| 46 |
-
<a href="https://huggingface.co/Adrien653/distilbert-rotten-tomatoes"
|
| 47 |
-
target="_blank">
|
| 48 |
-
Open Model Card
|
| 49 |
-
</a>
|
| 50 |
-
</div>
|
| 51 |
</body>
|
| 52 |
</html>
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="fr">
|
| 3 |
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
|
| 6 |
+
<title>Sentiment Analysis (DistilBERT)</title>
|
| 7 |
+
|
| 8 |
<style>
|
| 9 |
body {
|
| 10 |
+
font-family: sans-serif;
|
| 11 |
+
max-width: 640px;
|
| 12 |
+
margin: 40px auto;
|
| 13 |
+
padding: 0 16px;
|
| 14 |
}
|
| 15 |
+
|
| 16 |
+
textarea {
|
| 17 |
+
width: 100%;
|
| 18 |
+
box-sizing: border-box;
|
|
|
|
|
|
|
| 19 |
}
|
| 20 |
+
|
| 21 |
+
.bar {
|
| 22 |
+
background: #eee;
|
| 23 |
+
border-radius: 4px;
|
| 24 |
+
margin: 6px 0;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
.fill {
|
| 28 |
+
background: #3f51b5;
|
| 29 |
+
color: white;
|
| 30 |
+
padding: 4px 8px;
|
| 31 |
+
border-radius: 4px;
|
| 32 |
+
white-space: nowrap;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
button {
|
| 36 |
+
margin: 10px 4px 10px 0;
|
| 37 |
}
|
| 38 |
</style>
|
| 39 |
</head>
|
| 40 |
|
| 41 |
<body>
|
|
|
|
| 42 |
|
| 43 |
+
<h1>🎬 Sentiment Analysis (DistilBERT)</h1>
|
| 44 |
+
|
| 45 |
+
<p>
|
| 46 |
+
DistilBERT fine-tuné sur le dataset
|
| 47 |
+
<code>rotten_tomatoes</code>.
|
| 48 |
+
Le modèle est exécuté directement dans le navigateur
|
| 49 |
+
avec ONNX et Transformers.js.
|
| 50 |
+
</p>
|
| 51 |
+
|
| 52 |
+
<textarea
|
| 53 |
+
id="text"
|
| 54 |
+
rows="4"
|
| 55 |
+
placeholder="Enter a movie review...">
|
| 56 |
+
This movie was absolutely fantastic!
|
| 57 |
+
</textarea>
|
| 58 |
+
|
| 59 |
+
<br>
|
| 60 |
+
|
| 61 |
+
<button id="btn" disabled>
|
| 62 |
+
Analyser
|
| 63 |
+
</button>
|
| 64 |
+
|
| 65 |
+
<button id="positive" type="button">
|
| 66 |
+
Exemple positif
|
| 67 |
+
</button>
|
| 68 |
+
|
| 69 |
+
<button id="negative" type="button">
|
| 70 |
+
Exemple négatif
|
| 71 |
+
</button>
|
| 72 |
+
|
| 73 |
+
<div id="result">
|
| 74 |
+
Chargement du modèle...
|
| 75 |
+
</div>
|
| 76 |
+
|
| 77 |
+
<script type="module">
|
| 78 |
+
|
| 79 |
+
import { pipeline }
|
| 80 |
+
from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.1";
|
| 81 |
+
|
| 82 |
+
const result = document.getElementById("result");
|
| 83 |
+
const btn = document.getElementById("btn");
|
| 84 |
+
const text = document.getElementById("text");
|
| 85 |
+
|
| 86 |
+
document.getElementById("positive").onclick = () => {
|
| 87 |
+
text.value =
|
| 88 |
+
"This movie was absolutely fantastic, a real masterpiece!";
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
document.getElementById("negative").onclick = () => {
|
| 92 |
+
text.value =
|
| 93 |
+
"A total waste of time, I fell asleep halfway through.";
|
| 94 |
+
};
|
| 95 |
+
|
| 96 |
+
try {
|
| 97 |
+
|
| 98 |
+
const classifier = await pipeline(
|
| 99 |
+
"text-classification",
|
| 100 |
+
"Adrien653/distilbert-rotten-tomatoes",
|
| 101 |
+
{ dtype: "fp32" }
|
| 102 |
+
);
|
| 103 |
+
|
| 104 |
+
result.textContent =
|
| 105 |
+
"Modèle chargé. Entrez un texte.";
|
| 106 |
+
|
| 107 |
+
btn.disabled = false;
|
| 108 |
+
|
| 109 |
+
btn.onclick = async () => {
|
| 110 |
+
|
| 111 |
+
result.textContent =
|
| 112 |
+
"Analyse en cours...";
|
| 113 |
+
|
| 114 |
+
const predictions =
|
| 115 |
+
await classifier(text.value, { top_k: null });
|
| 116 |
+
|
| 117 |
+
result.innerHTML = predictions.map(p =>
|
| 118 |
+
|
| 119 |
+
`<div class="bar">
|
| 120 |
+
<div class="fill"
|
| 121 |
+
style="width:${Math.max(8, p.score * 100)}%">
|
| 122 |
+
${p.label} :
|
| 123 |
+
${(p.score * 100).toFixed(1)} %
|
| 124 |
+
</div>
|
| 125 |
+
</div>`
|
| 126 |
+
|
| 127 |
+
).join("");
|
| 128 |
+
|
| 129 |
+
};
|
| 130 |
+
|
| 131 |
+
}
|
| 132 |
+
catch (error) {
|
| 133 |
+
|
| 134 |
+
console.error(error);
|
| 135 |
+
|
| 136 |
+
result.textContent =
|
| 137 |
+
"Erreur pendant le chargement : " + error.message;
|
| 138 |
|
| 139 |
+
}
|
|
|
|
| 140 |
|
| 141 |
+
</script>
|
|
|
|
|
|
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
</body>
|
| 144 |
</html>
|