ombui commited on
Commit
31fe028
·
verified ·
1 Parent(s): c46d0e4

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +8 -12
  2. app.py +33 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,13 +1,9 @@
1
- ---
2
- title: Objectdetection
3
- emoji: 🏆
4
- colorFrom: purple
5
- colorTo: pink
6
- sdk: gradio
7
- sdk_version: 5.24.0
8
- app_file: app.py
9
- pinned: false
10
- short_description: objectdetection
11
- ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
1
+ # GeoAI Mask R-CNN Object Detector
 
 
 
 
 
 
 
 
 
 
2
 
3
+ This app uses a custom Mask R-CNN model trained with the GeoAI library to detect objects in aerial/satellite imagery.
4
+ Upload a 512x512 GeoTIFF tile to see the detected objects as a GeoJSON file.
5
+
6
+ ## Instructions
7
+ 1. Upload a GeoTIFF tile.
8
+ 2. Click submit.
9
+ 3. Download the resulting GeoJSON with detected objects.
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import geoai
3
+ import torch
4
+
5
+ model_path = "best_model.pth"
6
+ output_mask = "prediction.tif"
7
+ output_vector = "prediction.geojson"
8
+
9
+ def detect_objects(input_image):
10
+ input_image.save("input.tif")
11
+
12
+ geoai.object_detection(
13
+ image_path="input.tif",
14
+ output_path=output_mask,
15
+ model_path=model_path,
16
+ window_size=512,
17
+ overlap=256,
18
+ confidence_threshold=0.5,
19
+ batch_size=4,
20
+ num_channels=3,
21
+ )
22
+
23
+ geoai.orthogonalize(output_mask, output_vector, epsilon=2)
24
+
25
+ return output_vector
26
+
27
+ gr.Interface(
28
+ fn=detect_objects,
29
+ inputs=gr.Image(type="pil", label="Upload GeoTIFF"),
30
+ outputs="file",
31
+ title="Object Detection with GeoAI Mask R-CNN",
32
+ description="Upload a 512x512 GeoTIFF to detect objects using a custom-trained Mask R-CNN model."
33
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ geoai-py
3
+ torch