geocongoai 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geocongoai-0.1.0/LICENSE +21 -0
- geocongoai-0.1.0/MANIFEST.in +6 -0
- geocongoai-0.1.0/PKG-INFO +109 -0
- geocongoai-0.1.0/README.md +81 -0
- geocongoai-0.1.0/docs/alphaearth.md +47 -0
- geocongoai-0.1.0/docs/geoscientifique_database.md +83 -0
- geocongoai-0.1.0/docs/install_ubuntu.md +40 -0
- geocongoai-0.1.0/docs/install_ubuntu_detailed.md +69 -0
- geocongoai-0.1.0/docs/prithvi.md +31 -0
- geocongoai-0.1.0/docs/publish.md +121 -0
- geocongoai-0.1.0/pyproject.toml +26 -0
- geocongoai-0.1.0/setup.cfg +10 -0
- geocongoai-0.1.0/src/geocongoai/__init__.py +47 -0
- geocongoai-0.1.0/src/geocongoai/client.py +231 -0
- geocongoai-0.1.0/src/geocongoai/exceptions.py +48 -0
- geocongoai-0.1.0/src/geocongoai/geoscientifique_database/__init__.py +36 -0
- geocongoai-0.1.0/src/geocongoai/geoscientifique_database/client.py +4 -0
- geocongoai-0.1.0/src/geocongoai/geoscientifique_database/exceptions.py +16 -0
- geocongoai-0.1.0/src/geocongoai/geoscientifique_database/models.py +18 -0
- geocongoai-0.1.0/src/geocongoai/gundua_engine/__init__.py +3 -0
- geocongoai-0.1.0/src/geocongoai/gundua_engine/analysis.py +135 -0
- geocongoai-0.1.0/src/geocongoai/ia/__init__.py +3 -0
- geocongoai-0.1.0/src/geocongoai/ia/alphaearth.py +92 -0
- geocongoai-0.1.0/src/geocongoai/ia/prithvi.py +69 -0
- geocongoai-0.1.0/src/geocongoai/models.py +144 -0
- geocongoai-0.1.0/src/geocongoai/vision/__init__.py +5 -0
- geocongoai-0.1.0/src/geocongoai/vision/bgremoval.py +48 -0
- geocongoai-0.1.0/src/geocongoai/vision/image_utils.py +30 -0
- geocongoai-0.1.0/src/geocongoai/vision/pansharpen.py +67 -0
- geocongoai-0.1.0/src/geocongoai/vision/qr.py +40 -0
- geocongoai-0.1.0/src/geocongoai.egg-info/PKG-INFO +109 -0
- geocongoai-0.1.0/src/geocongoai.egg-info/SOURCES.txt +41 -0
- geocongoai-0.1.0/src/geocongoai.egg-info/dependency_links.txt +1 -0
- geocongoai-0.1.0/src/geocongoai.egg-info/requires.txt +21 -0
- geocongoai-0.1.0/src/geocongoai.egg-info/top_level.txt +1 -0
- geocongoai-0.1.0/tests/__pycache__/test_geoscientifique_database.cpython-310-pytest-9.1.1.pyc +0 -0
- geocongoai-0.1.0/tests/__pycache__/test_greetings.cpython-310-pytest-9.1.1.pyc +0 -0
- geocongoai-0.1.0/tests/__pycache__/test_pansharpen.cpython-310-pytest-9.1.1.pyc +0 -0
- geocongoai-0.1.0/tests/__pycache__/test_qr.cpython-310-pytest-9.1.1.pyc +0 -0
- geocongoai-0.1.0/tests/test_geoscientifique_database.py +150 -0
- geocongoai-0.1.0/tests/test_pansharpen.py +56 -0
- geocongoai-0.1.0/tests/test_qr.py +23 -0
geocongoai-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GeoCongoAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: geocongoai
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK and Geospatial AI Utilities for GeoCongo AI
|
|
5
|
+
Author: GeoCongoAI
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: requests>=2.25.0
|
|
10
|
+
Provides-Extra: vision
|
|
11
|
+
Requires-Dist: qrcode[pil]; extra == "vision"
|
|
12
|
+
Requires-Dist: Pillow; extra == "vision"
|
|
13
|
+
Requires-Dist: rasterio; extra == "vision"
|
|
14
|
+
Requires-Dist: numpy; extra == "vision"
|
|
15
|
+
Requires-Dist: rembg; extra == "vision"
|
|
16
|
+
Provides-Extra: ia
|
|
17
|
+
Requires-Dist: torch; extra == "ia"
|
|
18
|
+
Requires-Dist: terratorch; extra == "ia"
|
|
19
|
+
Requires-Dist: rasterio; extra == "ia"
|
|
20
|
+
Requires-Dist: numpy; extra == "ia"
|
|
21
|
+
Requires-Dist: earthengine-api; extra == "ia"
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
25
|
+
Requires-Dist: mypy; extra == "dev"
|
|
26
|
+
Requires-Dist: ruff; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# GeoCongo AI — Python SDK & Geospatial Utilities (v0.1.0)
|
|
30
|
+
|
|
31
|
+
Bibliothèque Python officielle pour **GeoCongo AI** : accès aux Edge Functions Supabase, traitements d'images satellites et modèles d'IA géospatiaux.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🚀 Modules principaux
|
|
36
|
+
|
|
37
|
+
1. **`geocongoai.geoscientifique_database` (ou `GeoCongoClient`)** :
|
|
38
|
+
- Client SDK officiel pour interagir avec les Edge Functions Supabase :
|
|
39
|
+
- Agent RAG (`/rag-agent`) : synthèses et réponses documentées avec citations.
|
|
40
|
+
- Recherche Documentaire (`/search-documents`) : recherche sémantique avec filtres (domaine, catégorie, province).
|
|
41
|
+
- Recherche Géologique Multimodale (`/search-geological`) : recherche vectorielle (1536D) à travers roches, cartes, jeux de données et documents.
|
|
42
|
+
2. **`geocongoai.vision`** :
|
|
43
|
+
- `generate_qr` : génération de QR codes.
|
|
44
|
+
- `remove_background` : détourage d'image via `rembg`.
|
|
45
|
+
- `pansharpen_brovey` : fusion d'images multispectrales et panchromatiques (Brovey method).
|
|
46
|
+
3. **`geocongoai.ia`** :
|
|
47
|
+
- `PrithviClient` : wrapper pour les modèles d'IA géospatiaux Prithvi v2 via `terratorch`.
|
|
48
|
+
- `AlphaEarthClient` : wrapper pour l'échantillonnage de pixels via Google Earth Engine (GEE).
|
|
49
|
+
4. **`geocongoai.gundua_engine`** :
|
|
50
|
+
- `analyse_deterministe` : calculs d'indices spectraux (NDVI, NDWI) et analyse par règles.
|
|
51
|
+
- `analyse_ia_fondation` & `traiter_image_satellite`.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 🛠️ Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Installation de base avec le SDK Edge Functions
|
|
59
|
+
python -m pip install -e .
|
|
60
|
+
|
|
61
|
+
# Optionnel : support Vision (Pansharpening, QR, Rembg)
|
|
62
|
+
python -m pip install -e .[vision]
|
|
63
|
+
|
|
64
|
+
# Optionnel : support IA (Prithvi, PyTorch, Earth Engine)
|
|
65
|
+
python -m pip install -e .[ia]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 💻 Exemple d'utilisation rapide du SDK
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from geocongoai import GeoCongoClient
|
|
74
|
+
from geocongoai.exceptions import InsufficientBalanceError
|
|
75
|
+
|
|
76
|
+
# Initialisation du client avec la clé Supabase
|
|
77
|
+
client = GeoCongoClient(api_key="VOTRE_SUPABASE_ANON_KEY")
|
|
78
|
+
|
|
79
|
+
# 1. Poser une question à l'Agent RAG
|
|
80
|
+
try:
|
|
81
|
+
response = client.ask_rag(
|
|
82
|
+
query="Quels sont les indices de cobalt dans le Lualaba ?",
|
|
83
|
+
user_id="123e4567-e89b-12d3-a456-426614174000"
|
|
84
|
+
)
|
|
85
|
+
print("Réponse :", response.answer)
|
|
86
|
+
print("Sources :", response.sources)
|
|
87
|
+
except InsufficientBalanceError:
|
|
88
|
+
print("Veuillez recharger votre solde unités.")
|
|
89
|
+
|
|
90
|
+
# 2. Recherche documentaire filtrée
|
|
91
|
+
docs = client.search_documents(
|
|
92
|
+
query="cuivre et cobalt",
|
|
93
|
+
domain="Mines",
|
|
94
|
+
category="Thèse",
|
|
95
|
+
province="Lualaba"
|
|
96
|
+
)
|
|
97
|
+
print(f"Trouvé {docs.total_found} documents.")
|
|
98
|
+
|
|
99
|
+
# 3. Rechercher des échantillons de roches ou cartes
|
|
100
|
+
results = client.search_geological(
|
|
101
|
+
query="kimberlite diamant",
|
|
102
|
+
type="rocks",
|
|
103
|
+
province="Kasaï"
|
|
104
|
+
)
|
|
105
|
+
for item in results.results:
|
|
106
|
+
print(f"[{item.item_type}] {item.title} (Score: {item.similarity})")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Voir les guides détaillés dans le dossier `docs/`.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# GeoCongo AI — Python SDK & Geospatial Utilities (v0.1.0)
|
|
2
|
+
|
|
3
|
+
Bibliothèque Python officielle pour **GeoCongo AI** : accès aux Edge Functions Supabase, traitements d'images satellites et modèles d'IA géospatiaux.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🚀 Modules principaux
|
|
8
|
+
|
|
9
|
+
1. **`geocongoai.geoscientifique_database` (ou `GeoCongoClient`)** :
|
|
10
|
+
- Client SDK officiel pour interagir avec les Edge Functions Supabase :
|
|
11
|
+
- Agent RAG (`/rag-agent`) : synthèses et réponses documentées avec citations.
|
|
12
|
+
- Recherche Documentaire (`/search-documents`) : recherche sémantique avec filtres (domaine, catégorie, province).
|
|
13
|
+
- Recherche Géologique Multimodale (`/search-geological`) : recherche vectorielle (1536D) à travers roches, cartes, jeux de données et documents.
|
|
14
|
+
2. **`geocongoai.vision`** :
|
|
15
|
+
- `generate_qr` : génération de QR codes.
|
|
16
|
+
- `remove_background` : détourage d'image via `rembg`.
|
|
17
|
+
- `pansharpen_brovey` : fusion d'images multispectrales et panchromatiques (Brovey method).
|
|
18
|
+
3. **`geocongoai.ia`** :
|
|
19
|
+
- `PrithviClient` : wrapper pour les modèles d'IA géospatiaux Prithvi v2 via `terratorch`.
|
|
20
|
+
- `AlphaEarthClient` : wrapper pour l'échantillonnage de pixels via Google Earth Engine (GEE).
|
|
21
|
+
4. **`geocongoai.gundua_engine`** :
|
|
22
|
+
- `analyse_deterministe` : calculs d'indices spectraux (NDVI, NDWI) et analyse par règles.
|
|
23
|
+
- `analyse_ia_fondation` & `traiter_image_satellite`.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 🛠️ Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Installation de base avec le SDK Edge Functions
|
|
31
|
+
python -m pip install -e .
|
|
32
|
+
|
|
33
|
+
# Optionnel : support Vision (Pansharpening, QR, Rembg)
|
|
34
|
+
python -m pip install -e .[vision]
|
|
35
|
+
|
|
36
|
+
# Optionnel : support IA (Prithvi, PyTorch, Earth Engine)
|
|
37
|
+
python -m pip install -e .[ia]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 💻 Exemple d'utilisation rapide du SDK
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from geocongoai import GeoCongoClient
|
|
46
|
+
from geocongoai.exceptions import InsufficientBalanceError
|
|
47
|
+
|
|
48
|
+
# Initialisation du client avec la clé Supabase
|
|
49
|
+
client = GeoCongoClient(api_key="VOTRE_SUPABASE_ANON_KEY")
|
|
50
|
+
|
|
51
|
+
# 1. Poser une question à l'Agent RAG
|
|
52
|
+
try:
|
|
53
|
+
response = client.ask_rag(
|
|
54
|
+
query="Quels sont les indices de cobalt dans le Lualaba ?",
|
|
55
|
+
user_id="123e4567-e89b-12d3-a456-426614174000"
|
|
56
|
+
)
|
|
57
|
+
print("Réponse :", response.answer)
|
|
58
|
+
print("Sources :", response.sources)
|
|
59
|
+
except InsufficientBalanceError:
|
|
60
|
+
print("Veuillez recharger votre solde unités.")
|
|
61
|
+
|
|
62
|
+
# 2. Recherche documentaire filtrée
|
|
63
|
+
docs = client.search_documents(
|
|
64
|
+
query="cuivre et cobalt",
|
|
65
|
+
domain="Mines",
|
|
66
|
+
category="Thèse",
|
|
67
|
+
province="Lualaba"
|
|
68
|
+
)
|
|
69
|
+
print(f"Trouvé {docs.total_found} documents.")
|
|
70
|
+
|
|
71
|
+
# 3. Rechercher des échantillons de roches ou cartes
|
|
72
|
+
results = client.search_geological(
|
|
73
|
+
query="kimberlite diamant",
|
|
74
|
+
type="rocks",
|
|
75
|
+
province="Kasaï"
|
|
76
|
+
)
|
|
77
|
+
for item in results.results:
|
|
78
|
+
print(f"[{item.item_type}] {item.title} (Score: {item.similarity})")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Voir les guides détaillés dans le dossier `docs/`.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# AlphaEarth (GEE) - guide d'utilisation
|
|
2
|
+
|
|
3
|
+
Ce document explique comment configurer l'acces a Google Earth Engine (GEE)
|
|
4
|
+
et utiliser `geocongoai.ia.alphaearth.AlphaEarthClient` pour extraire des
|
|
5
|
+
echantillons de pixels prêts a etre transformes en embeddings par un modele.
|
|
6
|
+
|
|
7
|
+
Prerequis:
|
|
8
|
+
- Avoir un compte GEE et les droits necessaires.
|
|
9
|
+
- Installer `earthengine-api`:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install earthengine-api
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Authentification (service account recommande pour serveurs):
|
|
16
|
+
|
|
17
|
+
1. Creez une cle JSON pour votre compte de service dans Google Cloud.
|
|
18
|
+
2. Assignez au compte les roles necessaires pour acceder aux assets Earth Engine.
|
|
19
|
+
3. Dans Python:
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from geocongoai.ia.alphaearth import AlphaEarthClient
|
|
23
|
+
|
|
24
|
+
client = AlphaEarthClient(service_account='your-service-account@project.iam.gserviceaccount.com', credentials_json='/path/to/key.json')
|
|
25
|
+
client.authenticate()
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Exemple d'extraction d'echantillons (pixels) pour une geometrie donnee:
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from geocongoai.ia.alphaearth import AlphaEarthClient
|
|
32
|
+
import ee
|
|
33
|
+
|
|
34
|
+
client = AlphaEarthClient()
|
|
35
|
+
client.authenticate()
|
|
36
|
+
|
|
37
|
+
geom = ee.Geometry.Polygon([[ [29.4, -2.5], [29.5, -2.5], [29.5, -2.6], [29.4, -2.6] ]])
|
|
38
|
+
res = client.extract_embeddings(geometry=geom, start_date='2022-01-01', end_date='2022-12-31', bands=['B4','B3','B2'])
|
|
39
|
+
print(res.get('count'))
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Notes pratiques:
|
|
43
|
+
- La methode `extract_embeddings` retourne des vecteurs de pixels (pas encore
|
|
44
|
+
des embeddings). Vous pouvez soit deployer un endpoint qui prend ces vecteurs
|
|
45
|
+
et renvoie des embeddings, soit telecharger un modele et faire l'inference
|
|
46
|
+
localement.
|
|
47
|
+
- Pour traiter de grandes zones, utilisez les mecanismes d'export (ee.batch.Export) au lieu de `getInfo()`.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Guide du SDK `geoscientifique_database` (GeoCongo AI)
|
|
2
|
+
|
|
3
|
+
Ce module fournit un client Python typé permettant d'interagir directement avec les 3 Edge Functions Supabase de la plateforme **GeoCongo AI**.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Initialisation
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from geocongoai import GeoCongoClient
|
|
11
|
+
|
|
12
|
+
client = GeoCongoClient(
|
|
13
|
+
api_key="VOTRE_SUPABASE_ANON_KEY",
|
|
14
|
+
base_url="https://tjpopbzjzlrrolqdismq.supabase.co/functions/v1" # Optionnel
|
|
15
|
+
)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 2. Agent RAG (`/rag-agent`)
|
|
21
|
+
|
|
22
|
+
Permet de poser des questions complexes et d'obtenir des synthèses documentées.
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
response = client.ask_rag(
|
|
26
|
+
query="Quel est le potentiel géologique du Katanga ?",
|
|
27
|
+
user_id="123e4567-e89b-12d3-a456-426614174000",
|
|
28
|
+
conversation_id="optionnel-uuid",
|
|
29
|
+
voice_name="GeoCongo AI"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
print(response.answer)
|
|
33
|
+
for source in response.sources:
|
|
34
|
+
print(f"- {source.title} (Auteur: {source.author}, Score: {source.similarity})")
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 3. Recherche Documentaire (`/search-documents`)
|
|
40
|
+
|
|
41
|
+
Recherche sémantique ciblée sur les thèses, rapports et publications.
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
docs_response = client.search_documents(
|
|
45
|
+
query="cuivre et cobalt",
|
|
46
|
+
domain="Mines", # Optionnel
|
|
47
|
+
category="Thèse", # Optionnel
|
|
48
|
+
province="Lualaba" # Optionnel
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
print(f"Total trouvé : {docs_response.total_found}")
|
|
52
|
+
for doc in docs_response.results:
|
|
53
|
+
print(f"Fichier : {doc.title} -> {doc.document_url}")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 4. Recherche Géologique Multimodale (`/search-geological`)
|
|
59
|
+
|
|
60
|
+
Recherche vectorielle 1536D à travers roches, cartes, jeux de données et documents.
|
|
61
|
+
|
|
62
|
+
Valeurs acceptées pour `type` : `"all"`, `"documents"`, `"rocks"`, `"maps"`, `"datasets"`.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
geo_response = client.search_geological(
|
|
66
|
+
query="malachite et cuivre",
|
|
67
|
+
type="rocks",
|
|
68
|
+
province="Haut-Katanga"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
for item in geo_response.results:
|
|
72
|
+
print(f"[{item.item_type}] {item.title} (Score: {item.similarity})")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 5. Gestion des Erreurs
|
|
78
|
+
|
|
79
|
+
Toutes les exceptions dérivent de `GeoCongoError` :
|
|
80
|
+
|
|
81
|
+
* `InvalidParametersError` (HTTP 400) : Paramètres manquants ou invalides.
|
|
82
|
+
* `InsufficientBalanceError` (HTTP 402) : Solde d'unités épuisé.
|
|
83
|
+
* `ServerError` (HTTP 500) : Erreur serveur interne Supabase.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Installation système (Ubuntu / Debian) pour geocongoai
|
|
2
|
+
|
|
3
|
+
Ce guide couvre les dépendances système souvent requises pour `rasterio`,
|
|
4
|
+
`rembg` et autres bibliothèques natives.
|
|
5
|
+
|
|
6
|
+
1) Mettre à jour le système
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
sudo apt update && sudo apt upgrade -y
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
2) Installer dépendances communes (GDAL, PROJ, libjpeg, libpng, libwebp)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
sudo apt install -y build-essential python3-dev python3-venv \
|
|
16
|
+
gdal-bin libgdal-dev libgdal27 libproj-dev proj-bin \
|
|
17
|
+
libjpeg-dev libpng-dev libwebp-dev libtiff-dev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
3) Créer et activer un environnement virtuel
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python3 -m venv .venv
|
|
24
|
+
source .venv/bin/activate
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
4) Installer les dépendances Python recommandées pour `geocongoai[vision]`
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install -e .[vision]
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Remarques:
|
|
35
|
+
- Sur certaines distributions, `libgdal-dev` a un nom différent; consultez
|
|
36
|
+
la documentation de votre distribution.
|
|
37
|
+
- Pour `rembg`, il peut être nécessaire d'installer `libwebp` et d'autres
|
|
38
|
+
dépendances natives (fourni ci-dessus).
|
|
39
|
+
- Pour `torch`, suivez la page officielle (CPU ou CUDA) et installez la
|
|
40
|
+
version adaptée à votre matériel si vous activez `geocongoai[ia]`.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Installation système détaillée (Ubuntu/Debian)
|
|
2
|
+
|
|
3
|
+
Ce guide explique comment préparer un environnement Ubuntu/Debian pour développer et exécuter `geocongoai` (notamment `rasterio`, `rembg`, `torch` et outils GDAL/PROJ).
|
|
4
|
+
|
|
5
|
+
1) Mise à jour
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
sudo apt update && sudo apt upgrade -y
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
2) Paquets communs (Ubuntu 22.04+ / Debian 11+)
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
sudo apt install -y build-essential git curl ca-certificates \
|
|
15
|
+
python3-dev python3-venv python3-pip \
|
|
16
|
+
gdal-bin libgdal-dev proj-bin libproj-dev \
|
|
17
|
+
libjpeg-dev libpng-dev libwebp-dev libtiff-dev \
|
|
18
|
+
libgeos-dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Remarques par version:
|
|
22
|
+
- Ubuntu 20.04: certains paquets peuvent avoir des versions plus anciennes; utilisez les backports ou un PPA pour obtenir des versions récentes de GDAL si nécessaire.
|
|
23
|
+
- Ubuntu 22.04/24.04 et Debian 12+ contiennent des paquets récents pour `rasterio` et `gdal`.
|
|
24
|
+
|
|
25
|
+
3) Configuration virtuelle Python
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
python3 -m venv .venv
|
|
29
|
+
source .venv/bin/activate
|
|
30
|
+
python -m pip install --upgrade pip setuptools wheel
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
4) Installer les dépendances Python (vision)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install qrcode[pil] Pillow numpy
|
|
37
|
+
pip install rasterio
|
|
38
|
+
pip install rembg
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Notes pour `rasterio`:
|
|
42
|
+
- Si `rasterio` échoue à l'installation, vérifiez que `gdal-config` est dans le PATH. Exemple:
|
|
43
|
+
`export CPLUS_INCLUDE_PATH=/usr/include/gdal` avant le `pip install rasterio`.
|
|
44
|
+
|
|
45
|
+
Notes pour `rembg`:
|
|
46
|
+
- `rembg` installe `pymatting` et `opencv-python-headless`; s'assurer que `libwebp-dev` et `libjpeg-dev` sont présents.
|
|
47
|
+
|
|
48
|
+
5) Installer `torch` (IA)
|
|
49
|
+
|
|
50
|
+
Suivez la page officielle https://pytorch.org/get-started/locally/ pour sélectionner la bonne commande selon votre GPU/CPU et CUDA. Exemple (CPU-only):
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
6) Dépannage commun
|
|
57
|
+
- Erreur `gdal-config not found`: installez `libgdal-dev` et assurez-vous que `gdal-config` est accessible.
|
|
58
|
+
- Erreurs liées à `numpy`/`scipy`: installez d'abord `python3-dev` et `build-essential`.
|
|
59
|
+
|
|
60
|
+
7) Tester l'installation minimale
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
python - <<'PY'
|
|
64
|
+
from PIL import Image
|
|
65
|
+
import qrcode
|
|
66
|
+
import rasterio
|
|
67
|
+
print('Pillow, qrcode et rasterio OK')
|
|
68
|
+
PY
|
|
69
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# PrithviClient (geocongoai.ia.prithvi)
|
|
2
|
+
|
|
3
|
+
Installation recommandée (extras `ia`):
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
python -m pip install -e .[ia]
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Pré-requis:
|
|
10
|
+
- `torch` adapté à votre plateforme (GPU/CPU)
|
|
11
|
+
- `terratorch` (fournit `BACKBONE_REGISTRY`)
|
|
12
|
+
- `rasterio`, `numpy` pour la lecture des tiffs
|
|
13
|
+
|
|
14
|
+
Usage minimal:
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from geocongoai.ia import PrithviClient
|
|
18
|
+
|
|
19
|
+
client = PrithviClient(model_name="prithvi_eo_v2_300", pretrained=True)
|
|
20
|
+
# charger le modèle (lazy-load)
|
|
21
|
+
client.load_model()
|
|
22
|
+
|
|
23
|
+
# extraire des features depuis un TIF local
|
|
24
|
+
res = client.extract_deep_features("/path/to/image.tif")
|
|
25
|
+
print(res.keys())
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Notes:
|
|
29
|
+
- Le package ne contient pas les poids du modèle. `PrithviClient` construit le backbone via `terratorch`.
|
|
30
|
+
- Pour utiliser des poids custom, fournissez l'argument `build_kwargs` à `load_model()` ou configurez `terratorch` selon la documentation du fournisseur des poids.
|
|
31
|
+
- Les pipelines de prétraitement (mosaïque, normalisation) doivent être appliqués côté utilisateur ou ajoutés via `PrithviClient` avant l'appel `extract_deep_features`.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Guide de Publication PyPI — `geocongoai`
|
|
2
|
+
|
|
3
|
+
Ce guide explique étape par étape comment construire et publier le package Python **`geocongoai`** sur **PyPI** (et **TestPyPI**).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 📋 1. Prérequis & Outillage
|
|
8
|
+
|
|
9
|
+
Installez les outils officiels de packaging et de téléversement Python :
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
python -m pip install --upgrade pip
|
|
13
|
+
pip install build twine
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 🧹 2. Nettoyage & Génération du Build
|
|
19
|
+
|
|
20
|
+
Avant de construire le package, nettoyez les anciens fichiers de build :
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
rm -rf dist/ build/ src/*.egg-info geocongoai.egg-info
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Générez ensuite les fichiers de distribution (Source Distribution `.tar.gz` et Wheel `.whl`) :
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
python -m build
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Vérifiez que la métadonnée et la syntaxe de la description Markdown sont valides :
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
python -m twine check dist/*
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
*(Cette commande doit afficher `PASSED` pour les deux fichiers).*
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🧪 3. Étape 1 : Publication de test sur TestPyPI (Recommandé)
|
|
43
|
+
|
|
44
|
+
Avant de publier sur le PyPI officiel, il est fortement conseillé de tester le package sur **TestPyPI**.
|
|
45
|
+
|
|
46
|
+
1. Créez un compte sur [test.pypi.org](https://test.pypi.org/) s'il n'est pas encore créé.
|
|
47
|
+
2. Générez un API Token : **Account Settings** > **API tokens** > **Add API token**.
|
|
48
|
+
3. Téléversez le package sur TestPyPI :
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m twine upload --repository testpypi dist/*
|
|
52
|
+
```
|
|
53
|
+
- **Username** : `__token__`
|
|
54
|
+
- **Password** : `pypi-YOUR_TEST_PYPI_TOKEN_HERE`
|
|
55
|
+
|
|
56
|
+
4. Testez l'installation depuis TestPyPI dans un venv vierge :
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple geocongoai
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 🚀 4. Étape 2 : Publication officielle sur PyPI
|
|
65
|
+
|
|
66
|
+
Une fois la vérification sur TestPyPI validée :
|
|
67
|
+
|
|
68
|
+
1. Connectez-vous à votre compte officiel sur [pypi.org](https://pypi.org/).
|
|
69
|
+
2. Allez dans **Account Settings** > **API tokens** et créez un jeton d'accès pour `geocongoai`.
|
|
70
|
+
3. Lancez le téléversement sur PyPI :
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
python -m twine upload dist/*
|
|
74
|
+
```
|
|
75
|
+
- **Username** : `__token__`
|
|
76
|
+
- **Password** : `pypi-YOUR_OFFICIAL_PYPI_TOKEN`
|
|
77
|
+
|
|
78
|
+
4. Une fois publié, le package sera disponible immédiatement pour le monde entier via :
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install geocongoai
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🤖 5. Automatisation CI/CD via GitHub Actions (Optionnel)
|
|
87
|
+
|
|
88
|
+
Pour publier automatiquement à chaque création de Tag / Release GitHub :
|
|
89
|
+
|
|
90
|
+
1. Dans votre dépôt GitHub : **Settings** > **Secrets and variables** > **Actions** > **New repository secret**.
|
|
91
|
+
2. Créez un secret nommé `PYPI_API_TOKEN` avec la valeur de votre token PyPI (`pypi-...`).
|
|
92
|
+
3. Créez un fichier `.github/workflows/publish.yml` :
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
name: Publish to PyPI
|
|
96
|
+
|
|
97
|
+
on:
|
|
98
|
+
release:
|
|
99
|
+
types: [published]
|
|
100
|
+
|
|
101
|
+
jobs:
|
|
102
|
+
deploy:
|
|
103
|
+
runs-on: ubuntu-latest
|
|
104
|
+
steps:
|
|
105
|
+
- uses: actions/checkout@v4
|
|
106
|
+
- name: Set up Python
|
|
107
|
+
uses: actions/setup-python@v5
|
|
108
|
+
with:
|
|
109
|
+
python-version: '3.10'
|
|
110
|
+
- name: Install dependencies
|
|
111
|
+
run: |
|
|
112
|
+
python -m pip install --upgrade pip
|
|
113
|
+
pip install build twine
|
|
114
|
+
- name: Build package
|
|
115
|
+
run: python -m build
|
|
116
|
+
- name: Publish to PyPI
|
|
117
|
+
env:
|
|
118
|
+
TWINE_USERNAME: __token__
|
|
119
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
120
|
+
run: python -m twine upload dist/*
|
|
121
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel", "build"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "geocongoai"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK and Geospatial AI Utilities for GeoCongo AI"
|
|
9
|
+
authors = [ { name = "GeoCongoAI" } ]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"requests>=2.25.0",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[project.optional-dependencies]
|
|
17
|
+
vision = ["qrcode[pil]", "Pillow", "rasterio", "numpy", "rembg"]
|
|
18
|
+
ia = ["torch", "terratorch", "rasterio", "numpy", "earthengine-api"]
|
|
19
|
+
dev = ["pytest", "pytest-mock", "mypy", "ruff"]
|
|
20
|
+
|
|
21
|
+
[tool.setuptools.packages.find]
|
|
22
|
+
where = ["src"]
|
|
23
|
+
|
|
24
|
+
[tool.pytest.ini_options]
|
|
25
|
+
testpaths = ["tests"]
|
|
26
|
+
pythonpath = ["src"]
|