Files
klarbildbot/README.md
T
till 7c23c3f4c7 Klarbildbot v1.0 — AI-Bildaufbereitung (Freistellen + Upscaling) als Telegram-Bot
- Telegram-Bot (Polling) mit Inline-Menue: Klarbild x2/x4, Freistellen, kombiniert
- Upscaling via OpenCV dnn_superres (FSRCNN default, EDSR optional), gekachelt
- Freistellen via rembg (isnet-general-use, Alpha-Matting)
- Picdrop-Batch via SFTP (/picdrop)
- Health-Server (aiohttp) fuer Coolify, Zugriffsschutz via ALLOWED_USER_IDS
- Dockerfile backt Modelle (SR von raw.githubusercontent, rembg von HF-Mirror)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNQ8ghPfzAfsyVYd6HgFb6
2026-07-23 10:14:27 +00:00

49 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Klarbildbot
Self-hosted Telegram-Bot für **AI-Bildaufbereitung** alles lokal auf CPU, keine externen/US-APIs.
- 🔍 **Klarbild (Upscaling)** AI-Super-Resolution (OpenCV `dnn_superres`, FSRCNN/EDSR) + Entrauschung + Schärfung
- ✂️ **Freistellen** Hintergrund per AI entfernen (`rembg`, ISNet/U2Net) → PNG mit Transparenz
-**Freistellen + Klarbild** kombiniert
- 📁 **Picdrop-Batch** (optional) ganze Galerie per SFTP ziehen, verarbeiten, zurückladen
## Nutzung
1. Bild an den Bot senden (für volle Auflösung **als Datei**, nicht als komprimiertes Foto)
2. Aktion im Menü wählen
3. Ergebnis kommt als Datei zurück
Befehle: `/start`, `/help`, `/picdrop <ordner> up2|up4|cut`
## Stack
Python 3.11 · python-telegram-bot (Polling) · rembg + onnxruntime · opencv-contrib (dnn_superres) · aiohttp (Health) · paramiko (Picdrop-SFTP). Deployment: Docker → Coolify, Repo in Gitea.
## Lokal starten
```bash
pip install -r requirements.txt
bash scripts/fetch_models.sh models # SR-Modelle laden
export BOT_TOKEN=... MODELS_DIR=$PWD/models U2NET_HOME=$PWD/models/u2net
python -m app.bot
```
## Konfiguration
Siehe `.env.example`. Wichtig:
- `BOT_TOKEN` (Pflicht)
- `ALLOWED_USER_IDS` auf die eigene Telegram-ID setzen (Zugriffsschutz). `/start` zeigt die ID.
- `UPSCALE_MODEL=fsrcnn` (Default, schnell). `edsr` gibt mehr Detail, ist auf CPU aber sehr langsam.
- Picdrop: `PICDROP_USER` / `PICDROP_PASSWORD` setzen, um `/picdrop` zu aktivieren.
## Deployment (Coolify)
Dockerfile-Build. Modelle werden beim Build gebacken (SR-Modelle von raw.githubusercontent, rembg-Modell vom HuggingFace-Mirror). Health-Endpoint auf `:8080/health`. Bot läuft im Polling-Modus kein öffentlicher Webhook nötig, die Coolify-URL dient nur dem Health-Check.
## Hinweise
- Telegram-Bots können Dateien bis **20 MB** laden/senden.
- Auf schwachen Boxen (z. B. Hetzner CX33, 8 GB, keine GPU) `fsrcnn` + `MAX_INPUT_EDGE≤1600` + `TILE_SIZE=256` lassen.
- Für Real-ESRGAN-Qualität `ENABLE_REALESRGAN=1` + ONNX-Modell hinterlegen (stärkere Box/GPU empfohlen).