---
metadata:
  - name: generator
    content: Diplodoc Platform v5.44.0
alternate:
  - https://yandex.ru/support/tasks-requester/ru/tutorials/image-segmentation-appendix.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/support/tasks-requester/ru/llms.txt

# Приложение: полный код всех проектов

<!-- source: ru/_includes/button-text.md -->
Напишите нам, если не нашли ответ в Справке. Вы можете приложить скриншоты или видео, чтобы ускорить помощь:
<!-- endsource: ru/_includes/button-text.md -->

<a class="support_btn msg" target="_blank" href="https://yandex.ru/chat?context=%7B%22entrypoint%22%3A%22%7B%5C%22page_name%5C%22%3A%5C%22tutorials-image-segmentation-appendix%5C%22%2C%5C%22a_pageurl%5C%22%3A%5C%22https%3A%2F%2Fyandex.ru%2Fsupport%2Ftasks-requester%2Fru%2Ftutorials%2Fimage-segmentation-appendix%5C%22%7D%22%7D#/user/bb41c200-08e6-94b4-5c5b-e9694fa7b06e">Написать в чат</a>  <a class="support_btn" target="_blank" href="https://t.me/YandexTasksSupport_Bot">Написать в Telegram</a>

## Проект 1. Содержит ли изображение определенный объект? {#image-segmentation-project-1}

{% cut "Спецификации" %}

#|
||**Входные данные:**|**Выходные данные:**||
||
```json
{
    "image": {
        "type": "url",
        "hidden": false,
        "required": true
    }
}
```
|
```json {
    "result": {
        "type": "string",
        "hidden": false,
        "required": true
    }
}
```
||
|#

{% endcut %}

{% cut "Блок HTML" %}

```html
{{img src=image width="100%" height="400px"}}
<div>Есть ли на картинке <b>дорожный знак</b>?<div>
<div> {{field type="radio" name="result" value="OK" label="Да" hotkey="1"}}
{{field type="radio" name="result" value="BAD" label="Нет" hotkey="2"}}
{{field type="radio" name="result" value="404" label="Ошибка загрузки" hotkey="3"}}</div>
```

{% endcut %}

{% cut "Блок JavaScript" %}

```javascript
exports.Task = extend(TolokaHandlebarsTask, function(options) {
    TolokaHandlebarsTask.call(this, options);
}, {
    onRender: function() {
        // DOM element for task is formed (available via #getDOMElement())
    },
    onDestroy: function() {
        // Task is completed. Global resources can be released (if used)
    }
});

function extend(ParentClass, constructorFunction, prototypeHash) {
    constructorFunction = constructorFunction || function() {};
    prototypeHash = prototypeHash || {};
    if (ParentClass) {
        constructorFunction.prototype = Object.create(ParentClass.prototype);
    }
    for (var i in prototypeHash) {
        constructorFunction.prototype[i] = prototypeHash[i];
    }
    return constructorFunction;
}
```

{% endcut %}

## Проект 2. Выделить объект на изображении {#image-segmentation-project-1}

{% cut "Спецификации" %}

#|
||**Входные данные:**|**Выходные данные:**||
||
```json
{
    "image": {
        "type": "url",
        "hidden": false,
        "required": true
    }
}
```
|
```json
{
    "result": {
        "type": "string",
        "hidden": false,
        "required": true
    }
}
```
||
|#

{% endcut %}

{% cut "Блок HTML" %}

```html
{{field type="image-annotation" name="result" src=image}}
```

{% endcut %}

{% cut "Блок JavaScript" %}

1. <!-- source: ru/guide/_includes/contents/t-components/image-annotation/p_tgf_nsv_wlb.md -->
   Подключите библиотеку `image-annotation.js` (нажмите <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none"><path fill="#000" d="m11.967 12.675.626 1.389a.5.5 0 0 1-.205.638l-.775.448a.5.5 0 0 1-.656-.141l-.895-1.244a1.433 1.433 0 0 0-2.565.345l-.538 1.425a.5.5 0 0 1-.597.306l-.865-.231a.5.5 0 0 1-.364-.564l.248-1.512a1.433 1.433 0 0 0-2.058-1.57l-1.389.627a.5.5 0 0 1-.638-.205l-.448-.776a.5.5 0 0 1 .141-.656l1.244-.894a1.433 1.433 0 0 0-.345-2.565L.463 6.958a.5.5 0 0 1-.306-.597l.232-.865a.5.5 0 0 1 .563-.364l1.512.247a1.433 1.433 0 0 0 1.57-2.058l-.627-1.388a.5.5 0 0 1 .206-.638l.775-.448a.5.5 0 0 1 .656.141l.894 1.244a1.433 1.433 0 0 0 2.565-.345L9.04.46a.5.5 0 0 1 .597-.306l.865.231a.5.5 0 0 1 .364.564l-.247 1.512a1.433 1.433 0 0 0 2.058 1.57l1.388-.627a.5.5 0 0 1 .639.205l.447.776a.5.5 0 0 1-.141.655l-1.244.895a1.432 1.432 0 0 0 .345 2.565l1.425.538a.5.5 0 0 1 .306.597l-.231.865a.5.5 0 0 1-.564.364l-1.512-.248a1.433 1.433 0 0 0-1.57 2.058l.002.001zM7.172 11.09a3.199 3.199 0 1 0 1.656-6.182 3.2 3.2 0 0 0-1.656 6.182z"/></svg> в блоке **Интерфейс задания** на странице проекта).
   <!-- endsource: ru/guide/_includes/contents/t-components/image-annotation/p_tgf_nsv_wlb.md -->

1. ```javascript
    exports.Task = extend(TolokaHandlebarsTask, function (options) {
    TolokaHandlebarsTask.call(this, options);
    }, {
    onRender: function() {
    // DOM element for task is formed (available via #getDOMElement())
    },
    onDestroy: function() {
    // Task is completed. Global resources can be released (if used)
    }
    });

    function extend(ParentClass, constructorFunction, prototypeHash) {
    constructorFunction = constructorFunction || function () {};
    prototypeHash = prototypeHash || {};
    if (ParentClass) {
    constructorFunction.prototype = Object.create(ParentClass.prototype);
    }
    for (var i in prototypeHash) {
    constructorFunction.prototype[i] = prototypeHash[i];
    }
    return constructorFunction;
    }

    ```

{% endcut %}

{% cut "Блок CSS" %}

```css
.image-annotation-editor__shape-polygon {
display: none;
}
.image-annotation-editor__annotation-layer {
height: max-content;
}
```

{% endcut %}

## Проект 3. Верно ли выделены объекты на изображении? {#image-segmentation-project-1}

{% cut "Спецификации" %}

#|
||**Входные данные:**|**Выходные данные:**||
||
```json
{
    "image": {
        "type": "url",
        "hidden": false,
        "required": true
    },
    "selection": {
        "type": "json",
        "hidden": false,
        "required": false
    },
    "assignment_id": {
        "type": "string",
        "hidden": true,
        "required": true
    }
}
```
|
```json
{
    "result": {
        "type": "string",
        "hidden": false,
        "required": true
    }
}
```
||
|#

{% endcut %}

{% cut "Блок HTML" %}

```html
{{field type="image-annotation" name="object" annotations=selection}}
 {{field type="radio" name="result" value="OK" label="Верно" hotkey="1"}}
  {{field type="radio" name="result" value="BAD" label="Неверно" hotkey="2"}}
```

{% endcut %}

{% cut "JavaScript" %}

```javascript
exports.Task = extend(TolokaHandlebarsTask, function(options) {
    TolokaHandlebarsTask.call(this, options);
}, {
    onRender: function() {
        // DOM element for task is formed (available via #getDOMElement())
    },
    onDestroy: function() {
        // Task is completed. Global resources can be released (if used)
    }
});

function extend(ParentClass, constructorFunction, prototypeHash) {
    constructorFunction = constructorFunction || function() {};
    prototypeHash = prototypeHash || {};
    if (ParentClass) {
        constructorFunction.prototype = Object.create(ParentClass.prototype);
    }
    for (var i in prototypeHash) {
        constructorFunction.prototype[i] = prototypeHash[i];
    }
    return constructorFunction;
}
```

{% endcut %}

{% cut "CSS" %}

```css
/* disable polygon-editor controls */
.image-annotation-editor__shape-polygon {
  display: none;
}
.image-annotation-editor__annotation-layer {
  height: max-content;
}
```

{% endcut %}

<!-- source: ru/guide/_includes/contact-support.md -->
<!-- source: ru/_includes/btn-style.md -->

<!-- endsource: ru/_includes/btn-style.md -->

[Написать в службу поддержки](https://yandex.ru/support/tasks-requester/ru/guide/troubleshooting/support.md){.support_btn}
<!-- endsource: ru/guide/_includes/contact-support.md -->
