#author("2025-02-25T09:23:39+09:00","default:ait-survey","ait-survey")
We are currently using a complex setup for deep learning in our lab, which involves Windows11, %%VcXsrv,%% WSL2, Ubuntu 20.04 (as well as the latest versions of Ubuntu available), %%Xfce4,%% Miniconda, pip, PyTorch, JetBrains Toolbox(on Windows only), and PyCharm. This setup provides a good environment for GPU execution and version management of Python modules. However, we are considering switching to a native Ubuntu setup, as it seems more suitable than using Windows with WSL2. We also plan to incorporate Docker into our workflow.
#author("2025-02-25T10:53:26+09:00","default:ait-survey","ait-survey")
We are currently using a complex setup for deep learning in our lab, which involves Windows11, %%VcXsrv,%% WSL2, Ubuntu 20.04 (as well as the latest versions of Ubuntu available), %%Xfce4,%% Miniconda, pip, PyTorch, JetBrains Toolbox(on Windows only but accessible from Ubuntu), and PyCharm. This setup provides a good environment for GPU execution and version management of Python modules. However, we are considering switching to a native Ubuntu setup, as it seems more suitable than using Windows with WSL2. We also plan to incorporate Docker into our workflow.

One concern we have is the occasional need to use Microsoft Word and Excel. We are unsure if these applications can be used on Linux and how to manage this requirement. We would appreciate any advice on this matter.

It's worth noting that setting up WSL2 can be challenging. As an alternative, using Windows with Miniconda, pip, PyTorch, JetBrains Toolbox, and PyCharm might be a more straightforward approach.
*Artificial Intelligence Execution Environment [#m82b4113]
どうやら&color(red){WSL2+PyTorch};は安定している.少なくとも,[[detectron2]]は,今のところ動いている.(WSLは250GB以上に割り当てできないのか?[[そんなことはない:https://ascii.jp/elem/000/004/075/4075005/]]よう(Windows10はダメで,Windows11ならOKか?)です.[[こんな:https://chat.openai.com/share/e4b5f1b8-d3a1-47f4-8adc-21bf7ef7ff63]]方法も.resize2fsコマンドを使用)
-WSL:Ubuntu 20.04.5 LTS (GNU/Linux 5.15.90.1-microsoft-standard-WSL2 x86_64)
-python:3.7.16 h7a1cb2a_0
-torch:torch 1.13.1+cu116 pypi_0 pypi
-NVIDIA CUDAコンパイラ(nvcc)のバージョン情報:Cuda compilation tools, release 12.1, V12.1.105(v11.6をインストールしたが,なぜか12.1になった)
--nvccのバージョン管理
---/usr/local/cuda-<version> という風に保存されている.

*labelme [#o3bb0439]
Used when specifying areas to be extracted (by drawing polygons, rectangles, or other shapes).~
そこから学習データとして画像で扱うならば(デフォルトはjsonファイル),そのフォーマットに関してRGBモード,Palleteモードが関わる(変換が必要な)ときがあり,その際はPythonの[[Pillow:https://python-pillow.org/]]モジュールの利用がいいのかも?画像の見た目ではモードの違いは分からない。(CycleGAN(特別な使い方ですが)や物体検出系の深層学習モデルで使用する際に)~
ここで大事なのは,後々の深層学習モデルで指定されるのはRGBモードかパレットモードか?~
-[[labelme:https://github.com/wkentaro/labelme]]でアノテーションの作成(jsonファイルができる)
-[[labelme_json_to_png:https://github.com/pei223/labelme_json_to_png]]でマスク画像を作成する(json2png).ただし,これではPモードが出力される.CycleGANとかではRGBモードが前提?なので,[[こちら:https://github.com/yoshiyama/labelme_json_to_png/blob/master/labelme_json_to_png_L.py]](labelme_json_to_png_&color(red){L};.py.ラベリングした複数のクラスのうち,特定のクラスだけをラベリングして画像化するならば,どの画像が対象になったかを保存できるプログラムにした方が使い勝手がいい.)で変換した方がいい.
 python labelme_json_to_png_L.py /mnt/c/Users/landslide/Desktop/niiyama/test_input -o=/mnt/c/Users/landslide/Desktop/niiyama/test_input_b -class_name="guardrail b" -pixel_value=255
-データの拡張~
-labelme2coco.py (labelme-main\examples\instance_segmentationにある.&color(red){detectron2の物体検出系モデル};への入力は,基本的に[[coco:https://cocodataset.org/#home]]フォーマット.annotations.jsonを作る.)
 python C:\Users\d18036\Desktop\labelme-main\examples\instance_segmentation\labelme2coco.py "C:\Users\d18036\Desktop\hodoukyou2023\hodoukyou-iroiro\kiritori-rear\test" "C:\Users\d18036\Desktop\hodoukyou2023\hodoukyou-iroiro\kiritori-rear\kiritori-henkan3" --labels "C:\Users\d18036\Desktop\hodoukyou2023\labels.txt"
要するに,~
python labelme2coco.py 入力ディレクトリ(LabelMeアノテーションを含む) 出力ディレクトリ(COCOアノテーションを保存する) ラベルファイル(クラス名のリストを含む)~
というコマンドラインの構造.~
なお,ここで使用するlabels.txtの中身は
 __ignore__
 _background_
 rail
labelme2coco.pyの~
ValueError: y1 must be greater than or equal to y0~
のエラー解決は~
 for shape in label_file.shapes:
    points = shape["points"]
    label = shape["label"]
    group_id = shape.get("group_id")
    shape_type = shape.get("shape_type", "polygon")
    if shape_type == "rectangle":
        (x1, y1), (x2, y2) = points
        x1, x2 = sorted([x1, x2])
        y1, y2 = sorted([y1, y2])
        points = [(x1, y1), (x2, y2)]
    mask = labelme.utils.shape_to_mask(img.shape[:2], points, shape_type)
    ...
としたら(If文のところの挿入,mask=の前まで.)いいようです.
-新たにlabelmeで作ったアノテーションデータをすでにあるCOCOフォーマットの学習データに追加するプログラムを作った~

*EfficientNet-Pytorch [#jfdb893a]
転移学習の[[プログラム:https://github.com/yoshiyama/EfficientNet-PyTorch]]ができた.~
(いまのところ回帰のプログラム.)~
ここのtqdmとかのブランチにある&color(red){以下のファイル};.
-transfer.py
-transfer_test.py


画像データセットと属性ファイルを&color(red){Training-Validation,Test};に分ける[[プログラム:https://github.com/yoshiyama/Data-TrainValTest]]ができた.~
(なぜ,Training-Validation,Testかというと,K-foldを使用前提)

*ipynb to py [#z9b73fb2]
jupyter nbconvert --to script input_file.ipynb

*[[Generative Image Inpainting]] [#g8fef4ff]
-入力データのフォーマットに要注意!!RGBAのpngフォーマットです.~

[[Roboflow:https://app.roboflow.com/login]] could be versatile and useful.~
*大規模データセット*** [#i844ec07]
-[[Cityscapes]]~
-ImageNet~

*GAN [#bd96a2e1]
-pix2pix
-CycleGAN [[論文:https://arxiv.org/pdf/1703.10593.pdf]]

pix2pixとCycleGANは,PyTorch系の[[この:https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix]]プログラムを使います.
**CycleGAN [#l58067eb]
★ノーマルモード
 python train.py --dataroot ./datasets/yellow2brown/ --name yellow2brown7 --model cycle_gan --gpu_ids 1 --n_epochs 200 --lr 0.0005
 python train.py --dataroot ./datasets/yellow2brown/ --name yellow2brown7 --model cycle_gan --gpu_ids 1
★&color(red){マスク};[[適用:https://chat.openai.com/share/16cf60a4-6fd3-4fc3-b936-d367ce795624]]~
訓練:
%%python train_mask.py --dataroot ./datasets/yellow2brown_mask_new/ --name yellow2brown_mask_new3 --model cycle_gan_mask --gpu_ids 1 --n_epochs 200 --lr 0.0005 --mask_weight 1 --dataset_mode unalignedmask%%
 python train_mask.py --dataroot ./datasets/yellow2brown_cut_mask/ --name yellow2brown_cut_mask_weight_3_norm --model cycle_gan_mask_norm --gpu_ids 0 --n_epochs 100 --mask_weight 3 --dataset_mode unalignedmask --load_size 256 --preprocess resize

テスト:
%%python test.py --dataroot ./datasets/yellow2brown_mask --name yellow2brown_mask150 --model cycle_gan --epoch 150 --gpu_ids 1%%
 python test.py --dataroot ./datasets/yellow2brown_cut_mask --name yellow2brown_cut_mask_weight_0t1_norm  --model cycle_gan_mask_norm_test --epoch 5 --gpu_ids 0 --phase test



ここで、

--dataroot はテストデータが保存されているパスを指定します。
--name は実験の名前を指定します。これは学習時に設定した名前と一致している必要があります。
--model はモデルの種類を指定します。CycleGANを使用する場合は cycle_gan と指定します。ここは要注意!
--epoch は使用するチェックポイントのエポック数を指定します。
注意点として、上記のコマンドでは、学習したモデルが保存されているディレクトリ (./checkpoints/horse2zebra_cyclegan) から対応するエポックのチェックポイントを自動的に読み込むことを期待しています。したがって、チェックポイントファイルが正しい場所に存在していることを確認してください。

Train/Test Tips [[日本語:https://chat.openai.com/share/7eba0b72-2a82-4583-95e8-ce50d428a829]]~
dataset例~
&ref(dataset2.jpg);~
マスクデータ例~
&ref(mask_d4s.jpg);~
*COCO Annotator [#ueba1d54]
例えば,インストール方法や使用法は,[[ここ:https://zenn.dev/syouya/articles/7632a74e73f657]]にある.~
基本的に,dockerを使うのだが,いろいろと見ていると+WSL2のように読めるが,docker+windowsでいけてる?ようです.~
インストール後は,ブラウザにて以下のURLにて扱える.
 http://localhost:5000/
以下のように,キーポイントの設定がし易いのがGood!
&ref(cocoano20.jpg);~
取り扱うデータは,当該ディレクトリのdatasetsに置くようです.
&ref(cocoadataset0.jpg);~
*deep sort [#of2c0df1]


[[測量研究室-愛知工業大学工学部土木工学科(Survey Lab., AIT)]]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS