-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/120 new specs #121
Conversation
* anno3d/model/label.pyに定義されていた、MetadataをInfoにして、実際のJson表現とは関係ない型にした * 消えた情報は、LabelSpecifier上に実装された。 * LabelSpecifierは更に抽象化される予定 * label_specifiers.pyに実Json構造に対して中立なインターフェースを追加 * それらを利用して、ProjectModifier / ProjectApi を変更
* 新規にプロジェクトを作る場合、新仕様のプロジェクトが作成されるようにした * 編集時に編集対象プロジェクトが旧仕様プロジェクトだった場合、その状態を維持するようにした * put_segment_labelのdefault_ignoreを必須の引数からはずした
anno3d/annofab/project.py
Outdated
def _project_modifiers(self, project_id: str) -> ProjectModifiers: | ||
current = self._modifiers_dic.get(project_id, None) | ||
if current is not None: | ||
return current | ||
|
||
project: Dict[str, Any] | ||
project, _ = self._client.get_project(project_id) | ||
conf: Dict[str, Any] = project["configuration"] | ||
specs_plugin = conf.get("extended_specs_plugin_id", None) | ||
|
||
# 仕様拡張プラグインが利用されているかどうかでLabelSpecifiersの実装を入れ替える | ||
if specs_plugin is None: | ||
new = ProjectModifiers(MetadataLabelSpecifiers()) | ||
else: | ||
# TODO Pluginに埋まってるバージョンを読んで選択出来るようにしたい | ||
# 現状は、1.0.1しか無い&pluginのdataclassが存在しないのでやってない | ||
new = ProjectModifiers(ExtendedSpecsLabelSpecifiersV1()) | ||
self._modifiers_dic[project_id] = new | ||
return new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
基本的に、新旧仕様の動作の切り替えはここで、LabelSpecifiersの実装を入れ替えることで行っている。
ただ、唯一、default_ignore
についてのコードだけ、LabelSpecifiersでは出来ない部分があるので、if
書いてある。
anno3d/annofab/project.py
Outdated
ignore_additional: Optional[IgnoreAdditionalDef] | ||
ignore_id: Optional[str] | ||
|
||
# 無視属性の追加は仕様拡張プラグインを使ってる場合は行わない | ||
# ここでifするの微妙だが、ProjectModifiersまで抽象化するのは手間なので、こうしておく | ||
if default_ignore is None or self._label_specifiers.extended_specs_plugin_version() is not None: | ||
ignore_additional = None | ||
ignore_id = None | ||
else: | ||
ignore_additional = default_ignore_additional if default_ignore else default_non_ignore_additional | ||
ignore_id = ignore_additional.id | ||
|
||
set_ignore = self._label_specifiers.ignore.set(ignore_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
切り替え用 if その1
anno3d/annofab/project.py
Outdated
ignore_additional: Optional[IgnoreAdditionalDef] | ||
ignore_id: Optional[str] | ||
|
||
# 無視属性の追加は仕様拡張プラグインを使ってる場合は行わない | ||
# ここでifするの微妙だが、ProjectModifiersまで抽象化するのは手間なので、こうしておく | ||
if default_ignore is None or self._label_specifiers.extended_specs_plugin_version() is not None: | ||
ignore_additional = None | ||
ignore_id = None | ||
else: | ||
ignore_additional = default_ignore_additional if default_ignore else default_non_ignore_additional | ||
ignore_id = ignore_additional.id | ||
|
||
set_ignore = self._label_specifiers.ignore.set(ignore_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
切り替え用 if その2
その1と全く同じコードだけど、とりあえず2つしかなくて隣り合って定義されているので、そのままにした。
python 関数による抽象化がめんどくさくて…
|
anno3d/annofab/constant.py
Outdated
builtin_3d_editor_plugin_id = "bdc16348-107e-4fbc-af4a-e482bc84a60f" | ||
|
||
# Annofabで定義されている標準三次元エディタ用仕様拡張プラグインのID(dev / production共通) | ||
builtin_3d_extend_specs_plugin_id = "703ababa-96ac-4920-8afb-d4f2bddac7e3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APIに合わせてextended
の方が良いと思います。
builtin_3d_extend_specs_plugin_id = "703ababa-96ac-4920-8afb-d4f2bddac7e3" | |
builtin_3d_extended_specs_plugin_id = "703ababa-96ac-4920-8afb-d4f2bddac7e3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annofab-api-python-clientでplugin_idを定義しました。これを参照すればplugin_idの定義する必要はないでしょうか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annofab-api-python-clientでplugin_idを定義しました。これを参照すればplugin_idの定義する必要はないでしょうか?
それはたしかにそうですね。
とはいえ、この情報をannofab-api-python-client
が持つべきかどうかは、ちょっと怪しい気がしますが。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
変数名変更しました e319150
確かに 8a798e6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新しいanno3d
コマンドで作成したプロジェクトと、従来のanno3d
コマンドで作成したプロジェクトに対して、以下のコマンドを実行できることを確認しました。
project put_cuboid_label
project put_segment_label --segment_type INSTANCE
project put_segment_label --segment_type SEMANTIC
@seraphr
|
どこから、 |
なるほど。 |
fix #120
サンプルコマンド
変数を適当に弄って、以下のコマンドを実行
私がテストに利用したデータは以下にアップロードしておいた
https://kurusugawa.jp/nextcloud/f/8863981