-
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
merge depth-anything case #26
base: main
Are you sure you want to change the base?
Conversation
@@ -16,6 +16,12 @@ RUN apt update && apt install -y --no-install-recommends wget ffmpeg=7:* \ | |||
zstd |
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.
このDockerfileは、依存関係のインストール方法を改善できます。
-
重複インストールの排除:
apt-get install
とpython3 -m pip install
の両方でいくつかのパッケージ(例:pycocotools
)をインストールしています。重複を削除し、1つのパッケージマネージャーに統一しましょう。 -
依存関係のグループ化:
# for depth anything
のようなコメントで区切るのではなく、関連するコマンドをまとめて、Dockerfileの可読性を向上させましょう。 -
ビルドコンテキストの最適化:
COPY
コマンドは可能な限りまとめて、レイヤーキャッシュを効率的に利用してビルド時間を短縮しましょう。 -
requirements.txtの利用: Pythonの依存関係は
requirements.txt
ファイルにまとめ、pip install -r requirements.txt
でインストールしましょう。これにより、依存関係の管理が容易になります。 -
不要なパッケージの削除:
eog
やnano
のような開発ツールは、最終的なイメージには不要なので削除しましょう。
@@ -0,0 +1,229 @@ | |||
from __future__ import annotations |
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.
print("going to camera.cap[0].read()")
やprint(f"{frame.shape=} {frame.dtype=}")
などのデバッグ用の出力は削除しましょう。self.camera.cap[0].read()
のように内部実装に依存するアクセスは避け、self.camera.read_frame()
のような抽象的なメソッドを提供しましょう。while True
ループ内で例外が発生した場合の処理が不足しています。適切に例外処理を行い、リソースを解放しましょう。cv2.imshow('Depth', results)
はパフォーマンスに影響を与える可能性があります。ストリーム表示が必須でない場合は、この部分を分離してオプションにしましょう。- 引数の処理を整理し、デフォルト値はクラス定義側に記述しましょう。
@@ -0,0 +1,91 @@ | |||
import argparse |
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.
- 関数の凝集性向上: ONNXエクスポートとTensorRT変換は別々の関数に分離しましょう。
- 引数の型ヒント活用:
save_path
をPath
型にしましょう。 - エラー処理の改善:
parser.parse
のエラー発生時に詳細を表示しましょう。 - マジックナンバーの排除:
2 << 30
のようなマジックナンバーには説明的な変数名を使いましょう。 - コメントの明確化: コメントはコードの意図を明確に説明するように心がけましょう。
@@ -0,0 +1,2 @@ | |||
#!/bin/sh |
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.
- エラー処理がない: scpコマンドが失敗した場合の処理がないため、エラーを無視してしまう可能性があります。
- 可読性が低い: シェルスクリプト内でコマンドを生成していますが、直接実行した方がシンプルでわかりやすいです。
- マジックナンバー:
scp -r weights
のweights
はハードコードされているため、汎用性が低いです。 - 変数名の改善:
$(logname)@$(hostname).local
は冗長で、$USER@$HOSTNAME.local
の方が一般的です。 - クォートの不足: 変数展開時にスペースを含む可能性があるため、変数をクォートする必要があります。
merge depth-anything case