Skip to content

Commit 562e2d2

Browse files
authored
Merge pull request #1594 from pierotofy/multiobj
Update GeoDeep, more object detection classes
2 parents ffc134a + 4dd1b07 commit 562e2d2

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

coreplugins/objdetect/api.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from app.plugins.worker import run_function_async
77
from django.utils.translation import gettext_lazy as _
88

9-
def detect(orthophoto, model, progress_callback=None):
9+
def detect(orthophoto, model, classes=None, progress_callback=None):
1010
import os
1111
from webodm import settings
1212

@@ -17,7 +17,7 @@ def detect(orthophoto, model, progress_callback=None):
1717
return {'error': "GeoDeep library is missing"}
1818

1919
try:
20-
return {'output': gdetect(orthophoto, model, output_type='geojson', max_threads=settings.WORKERS_MAX_THREADS, progress_callback=progress_callback)}
20+
return {'output': gdetect(orthophoto, model, output_type='geojson', classes=classes, max_threads=settings.WORKERS_MAX_THREADS, progress_callback=progress_callback)}
2121
except Exception as e:
2222
return {'error': str(e)}
2323

@@ -31,10 +31,20 @@ def post(self, request, pk=None):
3131
orthophoto = os.path.abspath(task.get_asset_download_path("orthophoto.tif"))
3232
model = request.data.get('model', 'cars')
3333

34-
if not model in ['cars', 'trees']:
34+
# model --> (modelID, classes)
35+
model_map = {
36+
'cars': ('cars', None),
37+
'trees': ('trees', None),
38+
'athletic': ('aerovision', ['tennis-court', 'track-field', 'soccer-field', 'baseball-field', 'swimming-pool', 'basketball-court']),
39+
'boats': ('aerovision', ['boat']),
40+
'planes': ('aerovision', ['plane']),
41+
}
42+
43+
if not model in model_map:
3544
return Response({'error': 'Invalid model'}, status=status.HTTP_200_OK)
3645

37-
celery_task_id = run_function_async(detect, orthophoto, model, with_progress=True).task_id
46+
model_id, classes = model_map[model]
47+
celery_task_id = run_function_async(detect, orthophoto, model_id, classes, with_progress=True).task_id
3848

3949
return Response({'celery_task_id': celery_task_id}, status=status.HTTP_200_OK)
4050

coreplugins/objdetect/public/ObjDetectPanel.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export default class ObjDetectPanel extends React.Component {
125125
}
126126

127127
handleDetect = () => {
128+
this.handleRemoveObjLayer();
128129
this.setState({detecting: true, error: "", progress: null});
129130
const taskId = this.state.task.id;
130131
this.saveInputValues();
@@ -175,7 +176,10 @@ export default class ObjDetectPanel extends React.Component {
175176
const { loading, permanentError, objLayer, detecting, model, progress } = this.state;
176177
const models = [
177178
{label: _('Cars'), value: 'cars'},
178-
{label: _('Trees'), value: 'trees'},
179+
{label: _('Trees'), value: 'trees'},
180+
{label: _('Athletic Facilities'), value: 'athletic'},
181+
{label: _('Boats'), value: 'boats'},
182+
{label: _('Planes'), value: 'planes'}
179183
]
180184

181185
let content = "";

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ drf-nested-routers==0.11.1
2121
funcsigs==1.0.2
2222
futures==3.1.1
2323
gunicorn==19.8.0
24-
geodeep==0.9.7
24+
geodeep==0.9.8
2525
itypes==1.1.0
2626
kombu==4.6.7
2727
Markdown==3.3.4

0 commit comments

Comments
 (0)