Skip to content
Snippets Groups Projects
Commit 6222e254 authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Connect to ML worker for classification.

parent 35e318cb
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ from django.contrib.postgres.indexes import GinIndex
from django.urls import reverse
from enumfields import EnumField, Enum
from arkindex.project.models import IndexableModel
from arkindex.project.celery import app as celery_app
from arkindex.documents.managers import ElementManager
from arkindex.project.fields import ArrayField
import uuid
......@@ -329,6 +330,15 @@ class Page(Element):
out.append(self.direction.value)
return ' '.join(out)
def ml_classify(self):
'''
Use a machine learning worker to classify the page
using its image
Celery is triggered through an external signature
'''
signature = celery_app.signature('arkindex_ml.tasks.classify')
return signature.delay(self.zone.image.get_thumbnail_url(max_width=None))
class Act(Element):
"""
......
......@@ -312,6 +312,12 @@ CELERY_ONCE = {
'default_timeout': 3600,
}
}
CELERY_TASK_ROUTES = {
# Route all machine learning work to specific workers
'arkindex_ml.*': {
'queue': 'ml',
}
}
CELERY_WORKING_DIR = os.environ.get('CELERY_WORKING_DIR', os.path.join(BASE_DIR, 'workers'))
# Email
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment