Skip to content

Commit

Permalink
Merge pull request #1594 from pierotofy/multiobj
Browse files Browse the repository at this point in the history
Update GeoDeep, more object detection classes
  • Loading branch information
pierotofy authored Jan 30, 2025
2 parents ffc134a + 4dd1b07 commit 562e2d2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
18 changes: 14 additions & 4 deletions coreplugins/objdetect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from app.plugins.worker import run_function_async
from django.utils.translation import gettext_lazy as _

def detect(orthophoto, model, progress_callback=None):
def detect(orthophoto, model, classes=None, progress_callback=None):
import os
from webodm import settings

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

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

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

if not model in ['cars', 'trees']:
# model --> (modelID, classes)
model_map = {
'cars': ('cars', None),
'trees': ('trees', None),
'athletic': ('aerovision', ['tennis-court', 'track-field', 'soccer-field', 'baseball-field', 'swimming-pool', 'basketball-court']),
'boats': ('aerovision', ['boat']),
'planes': ('aerovision', ['plane']),
}

if not model in model_map:
return Response({'error': 'Invalid model'}, status=status.HTTP_200_OK)

celery_task_id = run_function_async(detect, orthophoto, model, with_progress=True).task_id
model_id, classes = model_map[model]
celery_task_id = run_function_async(detect, orthophoto, model_id, classes, with_progress=True).task_id

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

Expand Down
6 changes: 5 additions & 1 deletion coreplugins/objdetect/public/ObjDetectPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default class ObjDetectPanel extends React.Component {
}

handleDetect = () => {
this.handleRemoveObjLayer();
this.setState({detecting: true, error: "", progress: null});
const taskId = this.state.task.id;
this.saveInputValues();
Expand Down Expand Up @@ -175,7 +176,10 @@ export default class ObjDetectPanel extends React.Component {
const { loading, permanentError, objLayer, detecting, model, progress } = this.state;
const models = [
{label: _('Cars'), value: 'cars'},
{label: _('Trees'), value: 'trees'},
{label: _('Trees'), value: 'trees'},
{label: _('Athletic Facilities'), value: 'athletic'},
{label: _('Boats'), value: 'boats'},
{label: _('Planes'), value: 'planes'}
]

let content = "";
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ drf-nested-routers==0.11.1
funcsigs==1.0.2
futures==3.1.1
gunicorn==19.8.0
geodeep==0.9.7
geodeep==0.9.8
itypes==1.1.0
kombu==4.6.7
Markdown==3.3.4
Expand Down

0 comments on commit 562e2d2

Please sign in to comment.