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

merge depth-anything case #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

katsunori-waragai
Copy link
Owner

merge depth-anything case

@@ -16,6 +16,12 @@ RUN apt update && apt install -y --no-install-recommends wget ffmpeg=7:* \
zstd

Choose a reason for hiding this comment

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

このDockerfileは、依存関係のインストール方法を改善できます。

  1. 重複インストールの排除: apt-get installpython3 -m pip install の両方でいくつかのパッケージ(例:pycocotools)をインストールしています。重複を削除し、1つのパッケージマネージャーに統一しましょう。

  2. 依存関係のグループ化: # for depth anything のようなコメントで区切るのではなく、関連するコマンドをまとめて、Dockerfileの可読性を向上させましょう。

  3. ビルドコンテキストの最適化: COPY コマンドは可能な限りまとめて、レイヤーキャッシュを効率的に利用してビルド時間を短縮しましょう。

  4. requirements.txtの利用: Pythonの依存関係は requirements.txt ファイルにまとめ、 pip install -r requirements.txt でインストールしましょう。これにより、依存関係の管理が容易になります。

  5. 不要なパッケージの削除: eognano のような開発ツールは、最終的なイメージには不要なので削除しましょう。

@@ -0,0 +1,229 @@
from __future__ import annotations

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

Choose a reason for hiding this comment

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

  1. 関数の凝集性向上: ONNXエクスポートとTensorRT変換は別々の関数に分離しましょう。
  2. 引数の型ヒント活用: save_pathPath 型にしましょう。
  3. エラー処理の改善: parser.parse のエラー発生時に詳細を表示しましょう。
  4. マジックナンバーの排除: 2 << 30 のようなマジックナンバーには説明的な変数名を使いましょう。
  5. コメントの明確化: コメントはコードの意図を明確に説明するように心がけましょう。

@@ -0,0 +1,2 @@
#!/bin/sh

Choose a reason for hiding this comment

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

  1. エラー処理がない: scpコマンドが失敗した場合の処理がないため、エラーを無視してしまう可能性があります。
  2. 可読性が低い: シェルスクリプト内でコマンドを生成していますが、直接実行した方がシンプルでわかりやすいです。
  3. マジックナンバー: scp -r weightsweights はハードコードされているため、汎用性が低いです。
  4. 変数名の改善: $(logname)@$(hostname).local は冗長で、$USER@$HOSTNAME.local の方が一般的です。
  5. クォートの不足: 変数展開時にスペースを含む可能性があるため、変数をクォートする必要があります。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant