fix: noms PlantNet en français (lang=fr) + sauvegarde image systématique sans plante liée
This commit is contained in:
@@ -13,7 +13,7 @@ async def identify(image_bytes: bytes, filename: str = "photo.jpg") -> List[dict
|
|||||||
async with httpx.AsyncClient(timeout=10.0) as client:
|
async with httpx.AsyncClient(timeout=10.0) as client:
|
||||||
resp = await client.post(
|
resp = await client.post(
|
||||||
PLANTNET_URL,
|
PLANTNET_URL,
|
||||||
params={"api-key": PLANTNET_KEY, "nb-results": 3},
|
params={"api-key": PLANTNET_KEY, "nb-results": 3, "lang": "fr"},
|
||||||
files={"images": (filename, image_bytes, "image/jpeg")},
|
files={"images": (filename, image_bytes, "image/jpeg")},
|
||||||
data={"organs": ["auto"]},
|
data={"organs": ["auto"]},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -184,18 +184,17 @@ async function saveAndLink() {
|
|||||||
'/api/upload',
|
'/api/upload',
|
||||||
fd,
|
fd,
|
||||||
)
|
)
|
||||||
if (linkPlantId.value !== null) {
|
// Toujours sauvegarder : lié à une plante si choisie, sinon dans la bibliothèque générale
|
||||||
await axios.post('/api/media', {
|
await axios.post('/api/media', {
|
||||||
entity_type: 'plante',
|
entity_type: linkPlantId.value !== null ? 'plante' : 'bibliotheque',
|
||||||
entity_id: linkPlantId.value,
|
entity_id: linkPlantId.value ?? 0,
|
||||||
url: uploaded.url,
|
url: uploaded.url,
|
||||||
thumbnail_url: uploaded.thumbnail_url,
|
thumbnail_url: uploaded.thumbnail_url,
|
||||||
identified_species: r.species,
|
identified_species: r.species,
|
||||||
identified_common: r.common_name,
|
identified_common: r.common_name,
|
||||||
identified_confidence: r.confidence,
|
identified_confidence: r.confidence,
|
||||||
identified_source: source.value,
|
identified_source: source.value,
|
||||||
})
|
})
|
||||||
}
|
|
||||||
emit('identified', { ...r, imageUrl: uploaded.url, plantId: linkPlantId.value })
|
emit('identified', { ...r, imageUrl: uploaded.url, plantId: linkPlantId.value })
|
||||||
emit('close')
|
emit('close')
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user