---
license: mit
title: Wildlife Log Processor
sdk: docker
emoji: 🦀
colorFrom: green
colorTo: blue
short_description: Wildlife Log Processor
---
[](https://www.python.org/) [](https://fastapi.tiangolo.com/) [](https://www.uvicorn.org/) [](https://huggingface.co/docs/transformers)
[](https://pytorch.org/) [](https://scikit-learn.org/) [](https://www.nltk.org/) [](https://www.sbert.net/) [](https://en.wikipedia.org/wiki/Tf%E2%80%93idf) [](https://www.docker.com/)
[](https://huggingface.co/spaces)
A modern, production-minded web application for uploading and processing wildlife log files. It helps you analyze, summarize, and report wildlife activity from raw text logs with minimal setup — optimized for local runs or deployment to Hugging Face Spaces (Docker).
---
## Why this project
- Built for readable, real-world wildlife logs: extractive summaries, event detection, anomaly detection, translations, sentiment and pattern analysis.
- Models and heavy pipelines are loaded once (module-level) to avoid repeated downloads and to keep request latency low.
- Local-first and privacy-friendly: you can run everything locally; no hardcoded API keys. Optional integrations (OpenRouter/OpenAI) are available for advanced summaries when you provide secrets.
---
## Features
| Feature | Description | Technique |
|---|---|---|
| Upload & Process | Upload plain-text wildlife logs or use the built-in demo to start processing instantly. | — |
| Extractive Summaries | TF‑IDF driven extractive summaries; optionally re-ranked with MiniLM semantic embeddings for improved relevance. |  
| Event Detection | Keyword and heuristic detectors for events such as poaching, injury, or unusual movement patterns. | Keywords + rules
| Pattern Detection | LDA topic modeling and clustering surface recurring activities and patrol patterns. | LDA / Clustering
| Sentiment Analysis | Hugging Face pipelines extract sentiment/emotion signals from notes and field observations. | 
| Anomaly Detection | IsolationForest and lightweight heuristics flag outliers, corrupted entries, and suspicious patterns. | IsolationForest
| Translation & Reports | Translate logs (Hindi demo) and download full, shareable report files. | Marian (HF)
| Demo Mode | One-click demo using `Log.txt` with an immediate download option for quick evaluation. | —
---
## Quickstart — Run locally (Windows PowerShell)
1. Create a virtual environment and activate it:
```powershell
python -m venv venv
venv\Scripts\activate
```
2. (Recommended) set local Hugging Face cache dirs so model files are stored under `.cache`:
```powershell
$env:HF_HOME = ".cache"
$env:TRANSFORMERS_CACHE = ".cache\transformers"
$env:TORCH_HOME = ".cache\torch"
```
3. Install dependencies and run the app:
```powershell
venv\Scripts\python.exe -m pip install --upgrade pip setuptools wheel
venv\Scripts\python.exe -m pip install -r requirements.txt
venv\Scripts\python.exe -m uvicorn backend.main:app --host 127.0.0.1 --port 7860
```
4. Open your browser at `http://127.0.0.1:7860`.
---
## Deployment (Hugging Face Spaces / Docker)
- This repo contains a `Dockerfile` configured to expose port `7860` for Spaces. Add your repository to a Docker Space and set any required environment secrets (e.g. `OPENROUTER_API_KEY`) in the Space settings.
---
## UI Highlights
- One-page interface: upload or use demo, process, then run analysis tiles (Daily Report, Log Summary, Event Detection, Sentiment, Pattern Detection, Translation, Anomaly Detection).
- Professional modern look with badges showing which technique is used for each tile (TF‑IDF, MiniLM, LDA, IsolationForest, etc.).
- Demo log button with built-in download for quick evaluation.
---
## Project layout
- `app.py` — optional entrypoint wrapper.
- `backend/main.py` — FastAPI app, static mounts and router inclusion.
- `backend/routes/main_routes.py` — API routes: upload, demo, run_function, download.
- `backend/services/` — modular services: `summarizer.py`, `sentiment.py`, `translation.py`, `anomaly.py`, `agentic.py`, etc.
- `backend/templates/` + `static/` — frontend template and assets (`css`, `js`, `bg.png`).
- `Log.txt` — curated demo log used by the demo flow.
---
## Notes & Tips
- If you want faster model downloads in CI or Spaces, set an authenticated `HF_TOKEN` or use smaller models during testing.
- To remove heavy downloads after development: delete the `venv` directory and the `.cache` directory (contains transformers/torch models).
- NLTK tokenizers will be auto-downloaded if missing; optionally preinstall them in your environment:
```powershell
venv\Scripts\python.exe -c "import nltk; nltk.download('punkt')"
```
---
## Contributing
Contributions welcome — open an issue or PR. Keep changes focused, add tests where practical, and follow the repository style (modular services, single-responsibility functions).
---
## License & Credits
This project is provided as-is for demonstration and utility. Add your preferred license as needed before publishing.
---
Enjoy — and thank you for building conservation tools that make it easier to turn raw field notes into actionable intelligence. 🐾