-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_task.py
34 lines (25 loc) · 1.03 KB
/
create_task.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import time
import base64
from urllib.parse import quote
from cvat_integration.cvat_manager import CVATUser, CVATOrganization, CVATProject, CVATTask, CVATManager
from settings import Settings
settings = Settings.get_instance()
if __name__ == '__main__':
username = 'user'
email = '[email protected]'
password = 'test_password_1'
basic_auth = f'{quote(username)}:{quote(email)}:{quote(password)}'
basic_auth = f'{base64.b64encode(basic_auth.encode()).decode()}'
parameters = {
'basic_auth': basic_auth,
'categories': ['dog', 'cat'],
'project_id': 'dog-cat-classification',
'webhook_target_url': settings.webhook_target_url
}
manager = CVATManager.init_CVAT_entities(**parameters)
task = CVATTask('annotation-task')
task_info = manager.recreate_task(task)
image_path = 'image/image_0.jpg'
with open(image_path, 'rb') as file:
task_content = base64.b64encode(file.read())
manager.attach_images(task, [task_content], [image_path])