Spaces:
Running
Running
Apply humanizer skill: drop signposting, switch to first person, add personality, more honest opener with the 8/10 number up front
Browse files
app.py
CHANGED
|
@@ -54,92 +54,119 @@ SPACE_URL = "https://huggingface.co/spaces/jbobym/wound-classifier"
|
|
| 54 |
TITLE: dict[str, str] = {
|
| 55 |
"en": (
|
| 56 |
"# Chronic Wound Classifier\n"
|
| 57 |
-
"
|
|
|
|
|
|
|
| 58 |
f"**Share this demo:** [{SPACE_URL}]({SPACE_URL})"
|
| 59 |
),
|
| 60 |
"fr": (
|
| 61 |
"# Classification des plaies chroniques\n"
|
| 62 |
-
"
|
|
|
|
|
|
|
|
|
|
| 63 |
f"**Partager cette démo :** [{SPACE_URL}]({SPACE_URL})"
|
| 64 |
),
|
| 65 |
}
|
| 66 |
|
| 67 |
DESCRIPTION: dict[str, str] = {
|
| 68 |
"en": """\
|
| 69 |
-
Upload a
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
4 times out of 10 in our testing. If it says Pressure ulcer, treat the answer with care.
|
| 86 |
-
|
| 87 |
-
**This is a research demo, not a medical device.** It does not diagnose, triage, or replace
|
| 88 |
-
clinician judgement. See *Approach* below for the methodology and headline accuracy.
|
| 89 |
""",
|
| 90 |
"fr": """\
|
| 91 |
-
Téléversez une photo
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
précaution.
|
| 109 |
-
|
| 110 |
-
**Ceci est une démonstration de recherche, et non un dispositif médical.** Le modèle n'établit
|
| 111 |
-
aucun diagnostic, ne fait pas de triage et ne remplace en rien le jugement clinique. Voir
|
| 112 |
-
*Approche* ci-dessous pour la méthodologie et l'exactitude principale.
|
| 113 |
""",
|
| 114 |
}
|
| 115 |
|
| 116 |
ARTICLE: dict[str, str] = {
|
| 117 |
"en": """\
|
| 118 |
-
|
| 119 |
-
public AZH Chronic Wound Database. The shipped checkpoint reaches 0.8152 top-1 on the held-out test
|
| 120 |
-
set (n=184); the best 10-fold ensemble of the same recipe averages 0.7989.
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
""",
|
| 130 |
"fr": """\
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
-
|
| 137 |
-
sur de vraies cohortes de patients. Aucun audit d'équité par teinte de peau (limite connue).
|
| 138 |
|
| 139 |
-
|
| 140 |
|
| 141 |
-
|
| 142 |
-
|
| 143 |
""",
|
| 144 |
}
|
| 145 |
|
|
@@ -167,30 +194,29 @@ LABELS: dict[str, dict[str, str]] = {
|
|
| 167 |
NOTE_LOW_CONFIDENCE: dict[str, str] = {
|
| 168 |
"en": (
|
| 169 |
"**Low confidence** (top class {top_label} at {top_pct}). "
|
| 170 |
-
"
|
| 171 |
-
|
| 172 |
-
"
|
| 173 |
-
"a wound."
|
| 174 |
),
|
| 175 |
"fr": (
|
| 176 |
"**Faible confiance** (classe principale {top_label} à {top_pct}). "
|
| 177 |
-
"
|
| 178 |
-
"
|
| 179 |
-
"
|
| 180 |
-
"
|
| 181 |
),
|
| 182 |
}
|
| 183 |
|
| 184 |
NOTE_PRESSURE: dict[str, str] = {
|
| 185 |
"en": (
|
| 186 |
-
"**Pressure
|
| 187 |
-
"
|
| 188 |
-
"
|
| 189 |
),
|
| 190 |
"fr": (
|
| 191 |
-
"**
|
| 192 |
-
"
|
| 193 |
-
"
|
| 194 |
),
|
| 195 |
}
|
| 196 |
|
|
|
|
| 54 |
TITLE: dict[str, str] = {
|
| 55 |
"en": (
|
| 56 |
"# Chronic Wound Classifier\n"
|
| 57 |
+
"A model I trained to look at a wound photo and guess which of four types it is. "
|
| 58 |
+
"It's right roughly 8 times out of 10; this page also tells you when not to trust it.\n\n"
|
| 59 |
+
"By **John Boby Mesadieu**.\n\n"
|
| 60 |
f"**Share this demo:** [{SPACE_URL}]({SPACE_URL})"
|
| 61 |
),
|
| 62 |
"fr": (
|
| 63 |
"# Classification des plaies chroniques\n"
|
| 64 |
+
"Un modèle que j'ai entraîné pour regarder une photo de plaie et deviner lequel des quatre "
|
| 65 |
+
"types c'est. Il a raison environ 8 fois sur 10 ; cette page vous dit aussi quand ne pas "
|
| 66 |
+
"lui faire confiance.\n\n"
|
| 67 |
+
"Par **John Boby Mesadieu**.\n\n"
|
| 68 |
f"**Partager cette démo :** [{SPACE_URL}]({SPACE_URL})"
|
| 69 |
),
|
| 70 |
}
|
| 71 |
|
| 72 |
DESCRIPTION: dict[str, str] = {
|
| 73 |
"en": """\
|
| 74 |
+
Upload a photo of a wound and the model picks one of four types (diabetic, pressure, surgical, or
|
| 75 |
+
venous), with a confidence percentage for each.
|
| 76 |
+
|
| 77 |
+
A few things to know before you try it:
|
| 78 |
+
|
| 79 |
+
- **Centre the wound in the photo.** The model only looks at a square in the middle of the image;
|
| 80 |
+
anything in the corners gets cropped out.
|
| 81 |
+
- **JPEG or PNG. That's it.**
|
| 82 |
+
- **Only upload wound photos.** The model has to pick one of the four types. If you give it
|
| 83 |
+
something else, it will still call it a wound. Watch the confidence percentage: if it comes back
|
| 84 |
+
under 50%, the model is probably guessing.
|
| 85 |
+
- **Pressure ulcers are the model's weak spot.** It gets them right roughly 4 times out of 10. When
|
| 86 |
+
it says Pressure, take the answer with a grain of salt.
|
| 87 |
+
|
| 88 |
+
This is a research demo, not a medical device. It doesn't diagnose, triage, or replace a
|
| 89 |
+
clinician's judgement. The *Approach* section below has the methodology and the headline accuracy.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
""",
|
| 91 |
"fr": """\
|
| 92 |
+
Téléversez une photo de plaie ; le modèle choisit l'un de quatre types (diabétique, escarre,
|
| 93 |
+
chirurgicale ou veineux) avec un pourcentage de confiance pour chacun.
|
| 94 |
+
|
| 95 |
+
À savoir avant d'essayer :
|
| 96 |
+
|
| 97 |
+
- **Centrez la plaie dans la photo.** Le modèle ne regarde qu'un carré au milieu de l'image ; tout
|
| 98 |
+
ce qui se trouve dans les coins est coupé.
|
| 99 |
+
- **JPEG ou PNG. C'est tout.**
|
| 100 |
+
- **Téléversez seulement des photos de plaie.** Le modèle doit choisir l'un des quatre types. Si
|
| 101 |
+
vous lui donnez autre chose, il l'appellera quand même une plaie. Surveillez le pourcentage de
|
| 102 |
+
confiance : sous 50 %, le modèle devine probablement.
|
| 103 |
+
- **L'escarre est le point faible du modèle.** Il la reconnaît correctement environ 4 fois sur 10.
|
| 104 |
+
Quand il dit Escarre, prenez la réponse avec précaution.
|
| 105 |
+
|
| 106 |
+
Ceci est une démonstration de recherche, pas un dispositif médical. Le modèle ne pose pas de
|
| 107 |
+
diagnostic, ne fait pas de triage et ne remplace pas le jugement clinique. La section *Approche*
|
| 108 |
+
ci-dessous donne la méthodologie et l'exactitude principale.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
""",
|
| 110 |
}
|
| 111 |
|
| 112 |
ARTICLE: dict[str, str] = {
|
| 113 |
"en": """\
|
| 114 |
+
### Approach
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
I trained an image classifier (EfficientNet-B0) on the AZH Chronic Wound Database, a public
|
| 117 |
+
research dataset of clinical wound photos. The training was set up so that the same patient's
|
| 118 |
+
photos never appeared in both the training and test sets; that detail matters more than it sounds,
|
| 119 |
+
because models on this dataset can otherwise inflate their accuracy by quietly memorising patients
|
| 120 |
+
instead of learning what wounds actually look like.
|
| 121 |
|
| 122 |
+
On the held-out test set of 184 photos, the version of the model running here gets the wound type
|
| 123 |
+
right 81 times out of 100. As a sanity check, I trained nine other versions of the same model on
|
| 124 |
+
slightly different slices of the data and averaged their predictions; that combined version scored
|
| 125 |
+
80 out of 100 on the same test, which suggests the headline number is not a fluke.
|
| 126 |
|
| 127 |
+
### Out of scope
|
| 128 |
+
|
| 129 |
+
Not for clinical decision-making. No claim of diagnostic accuracy on real patient cohorts. No
|
| 130 |
+
fairness audit across skin tones, which is a known gap.
|
| 131 |
+
|
| 132 |
+
### Author
|
| 133 |
+
|
| 134 |
+
John Boby Mesadieu.
|
| 135 |
+
|
| 136 |
+
### Dataset citation
|
| 137 |
+
|
| 138 |
+
Anisuzzaman et al. 2022, *Multi-modal wound classification using wound image and location by deep
|
| 139 |
+
neural network*, Sci. Rep. 12:20057.
|
| 140 |
""",
|
| 141 |
"fr": """\
|
| 142 |
+
### Approche
|
| 143 |
+
|
| 144 |
+
J'ai entraîné un classifieur d'images (EfficientNet-B0) sur la AZH Chronic Wound Database, un jeu
|
| 145 |
+
de données public de photos cliniques de plaies. L'entraînement a été configuré pour que les
|
| 146 |
+
photos d'un même patient n'apparaissent jamais à la fois dans le jeu d'entraînement et dans le jeu
|
| 147 |
+
de test ; ce détail compte, parce que les modèles entraînés sur ce jeu de données peuvent
|
| 148 |
+
autrement gonfler leur exactitude en mémorisant discrètement des patients plutôt qu'en apprenant à
|
| 149 |
+
quoi ressemble une plaie.
|
| 150 |
+
|
| 151 |
+
Sur le jeu de test retenu de 184 photos, la version du modèle déployée ici trouve le bon type de
|
| 152 |
+
plaie 81 fois sur 100. Comme contrôle, j'ai entraîné neuf autres versions du même modèle sur des
|
| 153 |
+
découpes légèrement différentes des données et fait la moyenne de leurs prédictions ; cette
|
| 154 |
+
version combinée a obtenu 80 sur 100 sur le même test, ce qui suggère que le chiffre principal
|
| 155 |
+
n'est pas un coup de chance.
|
| 156 |
+
|
| 157 |
+
### Hors champ
|
| 158 |
+
|
| 159 |
+
Pas pour la décision clinique. Aucune prétention d'exactitude diagnostique sur de vraies cohortes
|
| 160 |
+
de patients. Aucun audit d'équité par teinte de peau, ce qui constitue une limite connue.
|
| 161 |
+
|
| 162 |
+
### Auteur
|
| 163 |
|
| 164 |
+
John Boby Mesadieu.
|
|
|
|
| 165 |
|
| 166 |
+
### Référence du jeu de données
|
| 167 |
|
| 168 |
+
Anisuzzaman et coll. 2022, *Multi-modal wound classification using wound image and location by
|
| 169 |
+
deep neural network*, Sci. Rep. 12:20057.
|
| 170 |
""",
|
| 171 |
}
|
| 172 |
|
|
|
|
| 194 |
NOTE_LOW_CONFIDENCE: dict[str, str] = {
|
| 195 |
"en": (
|
| 196 |
"**Low confidence** (top class {top_label} at {top_pct}). "
|
| 197 |
+
"Probably one of two things: the photo isn't a clear close-up of a wound, or it is a "
|
| 198 |
+
"wound but not one of the four the model knows. Either way, the model still has to pick, "
|
| 199 |
+
"so do not lean on this answer."
|
|
|
|
| 200 |
),
|
| 201 |
"fr": (
|
| 202 |
"**Faible confiance** (classe principale {top_label} à {top_pct}). "
|
| 203 |
+
"L'une des deux choses, probablement : la photo n'est pas un gros plan clair d'une plaie, "
|
| 204 |
+
"ou c'est bien une plaie mais pas l'un des quatre types que le modèle connaît. Dans les "
|
| 205 |
+
"deux cas, le modèle est obligé de choisir quand même, alors ne vous appuyez pas sur "
|
| 206 |
+
"cette réponse."
|
| 207 |
),
|
| 208 |
}
|
| 209 |
|
| 210 |
NOTE_PRESSURE: dict[str, str] = {
|
| 211 |
"en": (
|
| 212 |
+
"**Pressure ulcers are the model's weak spot.** "
|
| 213 |
+
"It gets them right roughly 4 times out of 10. "
|
| 214 |
+
"When it says Pressure, take the answer with a grain of salt."
|
| 215 |
),
|
| 216 |
"fr": (
|
| 217 |
+
"**L'escarre est le point faible du modèle.** "
|
| 218 |
+
"Il la reconnaît correctement environ 4 fois sur 10. "
|
| 219 |
+
"Quand il dit Escarre, prenez la réponse avec précaution."
|
| 220 |
),
|
| 221 |
}
|
| 222 |
|