rinogeek commited on
Commit
33abd02
·
1 Parent(s): 8af76d0

Initial commit for Hugging Face Space

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. README.md +21 -0
  3. app.py +78 -0
  4. best.pt +3 -0
  5. requirements.txt +7 -0
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ *.pt filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: SATCAP-OCEANS
3
+ emoji: 🌊
4
+ colorFrom: blue
5
+ colorTo: slate
6
+ sdk: gradio
7
+ sdk_version: 4.12.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
+ # SATCAP-OCEANS
14
+
15
+ Analyse d'images satellites pour la surveillance des océans et des côtes.
16
+ Détection automatique des navires, infrastructures et autres objets d'intérêt.
17
+
18
+ ## Utilisation
19
+ 1. Uploadez une image satellite.
20
+ 2. Cliquez sur "Lancer l'Analyse".
21
+ 3. Visualisez les détections et les statistiques.
app.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ultralytics import YOLO
3
+ import cv2
4
+ import numpy as np
5
+ from PIL import Image
6
+ import os
7
+
8
+ # Load the model
9
+ model_path = "best.pt"
10
+ model = YOLO(model_path)
11
+
12
+ def predict(img):
13
+ if img is None:
14
+ return None, "Veuillez uploader une image."
15
+
16
+ # Run inference
17
+ results = model(img)
18
+
19
+ # Get annotated image
20
+ # results[0].plot() returns a numpy array (BGR)
21
+ annotated_img = results[0].plot()
22
+
23
+ # Convert BGR to RGB for Gradio
24
+ annotated_img_rgb = cv2.cvtColor(annotated_img, cv2.COLOR_BGR2RGB)
25
+
26
+ # Count detections
27
+ counts = {}
28
+ for box in results[0].boxes:
29
+ cls = int(box.cls[0])
30
+ label = model.names[cls]
31
+ counts[label] = counts.get(label, 0) + 1
32
+
33
+ # Format stats string
34
+ if not counts:
35
+ stats = "Aucun objet détecté."
36
+ else:
37
+ stats = "### Détections :\n"
38
+ for label, count in counts.items():
39
+ stats += f"- **{label}**: {count}\n"
40
+
41
+ return annotated_img_rgb, stats
42
+
43
+ # Create Gradio interface with a premium look
44
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="slate")) as demo:
45
+ gr.Markdown(
46
+ """
47
+ # 🌊 SATCAP-OCEANS : Détection par Satellite
48
+ ### Analyse d'images satellites pour la surveillance des océans et des côtes.
49
+
50
+ Déposez une image satellite ci-dessous pour détecter automatiquement les navires, les infrastructures et autres objets d'intérêt.
51
+ """
52
+ )
53
+
54
+ with gr.Row():
55
+ with gr.Column():
56
+ input_img = gr.Image(type="numpy", label="Image Satellite")
57
+ btn = gr.Button("Lancer l'Analyse", variant="primary")
58
+
59
+ with gr.Column():
60
+ output_img = gr.Image(label="Résultat de l'Analyse")
61
+ output_stats = gr.Markdown(label="Statistiques")
62
+
63
+ btn.click(fn=predict, inputs=input_img, outputs=[output_img, output_stats])
64
+
65
+ gr.Examples(
66
+ examples=[], # You can add example images here if you have any in the repo
67
+ inputs=input_img
68
+ )
69
+
70
+ gr.Markdown(
71
+ """
72
+ ---
73
+ Propulsé par **CosmoLABHub** | Modèle YOLOv8
74
+ """
75
+ )
76
+
77
+ if __name__ == "__main__":
78
+ demo.launch()
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8895d0ddf2db84fcd858cd4d6b7a15f0402b8b2125b29a1e3214cb3785644d73
3
+ size 52039826
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ gradio
2
+ ultralytics
3
+ opencv-python-headless
4
+ pillow
5
+ numpy
6
+ torch
7
+ torchvision