Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HuggingFace Model Wrapper for Semantic-Segmentation #3749

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

harimkang
Copy link
Contributor

@harimkang harimkang commented Jul 18, 2024

Summary

image
*pipeline: /base/data/semantic_segmentation.yaml & optimizer: AdamW (lr 0.0001)
*The current settings are probably not optimal for each model, so we should be able to improve performance based on the more optimal settings.

How to test

Install transformers
pip install transformers
or
pip install -e .[transformers]

API Examples

from otx.algo.segmentation.huggingface_model import HuggingFaceModelForSegmentation
from otx.engine import Engine

data_root = "/datasets/otx_v2_dataset/semantic_seg/kvasir_medium"

otx_model = HuggingFaceModelForSegmentation(
    model_name_or_path="nvidia/segformer-b0-finetuned-ade-512-512",
    label_info=2,
)

engine = Engine(
    data_root=data_root,
    model=otx_model,
    work_dir="otx-workspace-hf",
)

engine.train(max_epochs=2)
engine.test()
engine.export()
engine.test(checkpoint="otx-workspace-hf/exported_model.xml")

CLI Examples

(venv) ~/otx$ otx train \
    --model otx.algo.segmentation.huggingface_model.HuggingFaceModelForSegmentation \
    --model.model_name_or_path nvidia/segformer-b0-finetuned-ade-512-512 \
    --data_root /datasets/otx_v2_dataset/semantic_seg/kvasir_medium \
    --work_dir otx-workspace-hf-cli --max_epochs 3

Unit-Test:
image

Checklist

  • I have added unit tests to cover my changes.​
  • I have added integration tests to cover my changes.​
  • I have ran e2e tests and there is no issues.
  • I have added the description of my changes into CHANGELOG in my target branch (e.g., CHANGELOG in develop).​
  • I have updated the documentation in my target branch accordingly (e.g., documentation in develop).
  • I have linked related issues.

License

  • I submit my code changes under the same Apache License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below).
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

Copy link
Collaborator

@kprokofi kprokofi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work

Copy link
Contributor

@wonjuleee wonjuleee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@harimkang harimkang added this pull request to the merge queue Jul 19, 2024
Merged via the queue into openvinotoolkit:develop with commit f977254 Jul 19, 2024
22 checks passed
@harimkang harimkang deleted the harimkan/hf-seg branch July 19, 2024 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TEST Any changes in tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants