(self, request, pk=None)
| 52 | |
| 53 | class TaskObjDetect(TaskView): |
| 54 | def post(self, request, pk=None): |
| 55 | task = self.get_and_check_task(request, pk) |
| 56 | |
| 57 | if task.orthophoto_extent is None: |
| 58 | return Response({'error': _('No orthophoto is available.')}) |
| 59 | |
| 60 | orthophoto = os.path.abspath(task.get_asset_download_path("orthophoto.tif")) |
| 61 | model = request.data.get('model', 'cars') |
| 62 | |
| 63 | # model --> (modelID, classes) |
| 64 | model_map = { |
| 65 | 'cars': ('cars', None), |
| 66 | 'trees': ('trees', None), |
| 67 | 'athletic': ('aerovision', ['tennis-court', 'track-field', 'soccer-field', 'baseball-field', 'swimming-pool', 'basketball-court']), |
| 68 | 'boats': ('aerovision', ['boat']), |
| 69 | 'planes': ('aerovision', ['plane']), |
| 70 | } |
| 71 | |
| 72 | if not model in model_map: |
| 73 | return Response({'error': 'Invalid model'}, status=status.HTTP_200_OK) |
| 74 | |
| 75 | model_id, classes = model_map[model] |
| 76 | celery_task_id = run_function_async(detect, orthophoto, model_id, classes, task.crop.wkt if task.crop is not None else None, with_progress=True).task_id |
| 77 | |
| 78 | return Response({'celery_task_id': celery_task_id}, status=status.HTTP_200_OK) |
| 79 | |
| 80 | class TaskObjDownload(GetTaskResult): |
| 81 | def handle_output(self, output, result, **kwargs): |
nothing calls this directly
no test coverage detected