こすたろーんエンジニアの試行錯誤部屋

作成物の備忘録を書いていきますー

【pytorch】How to create a learning environment using the pytorch template

スポンサーリンク

I have been using the classyvision framework from pytoch to train my image classification model.
The framework is easy to use, but it is difficult to extend it by yourself...
I thought it would be possible to extend it with a template instead of a framework, so I looked for a template that looked good and tried it out.
This article is just a reminder.

contents

スポンサーリンク

abstract

How to create a learning environment using the pytorch template

1.requirement

1.1 requirement

Jetson Xavier NX
ubuntu18.04
docker
python3.6

1.2 Get Templates

The template used for this project is as follows
github.com

Clone from github with the following command

cd workspace
git clone https://github.com/victoresque/pytorch-template.git

1.3 create dockerfile&image

The dockerfile used this time is as follows

FROM nvcr.io/nvidia/l4t-pytorch:r32.4.4-pth1.6-py3

RUN pip3 install --upgrade pip
RUN pip3 install --ignore-installed PyYAML
RUN pip3 install tensorboard
RUN pip3 install pandas

Build

sudo docker build . -t pytorch_templete

1.4 run docker container

Start the docker container and enter the container

sudo docker run -it --rm --runtime nvidia -v /path/to/your/workspace/dir/:/workspace --workdir /workspace --network host pytorch_templete

2.sample run

Let's run the training of the image classification model using mnist and resnet this time.
The config.json file contains the above training by default, so we will use it as is.

python3 train.py -c config.json

The results of the evaluation after execution are as follows

    epoch          : 57
    loss           : 0.07924625007832926
    accuracy       : 0.9757558606973595
    top_k_acc      : 0.9974081753554502
    val_loss       : 0.03324085925061731
    val_accuracy   : 0.9901690729483283
    val_top_k_acc  : 0.999501329787234

Template-based learning is now available.

スポンサーリンク

3.refarence

github.com

【Stable Diffusion】try to use GhostMix for creteing an animated image generation model

スポンサーリンク

I have recently been experimenting with various models for generating animated images.
Last time I tried Dark Sushi Mix.
This time, I would like to use GhostMix to generate images.

contents

スポンサーリンク

abstract

What kind of images can be generated using GhostMix with google colab and dfiffusers.

1.requirement

Google Colab
Diffusers transformers==4.26.0
model : GhostMix

2.result

positive prompt

1girl, parted lips, blush, makeup, light smile, school uniform, classroom, light rays, glow, thighs, collarbone, narrow waist, (masterpiece), wallpaper

negative prompt

distorted face, badhandv4:0.6, extra fingers, fewer fingers, extra digit, bad hands, bad finger, head cut off, Easy Negative, disfigured, ugly, mutation, deformed, deformed face, long face, cross-eyed, long neck, cross-eyed, mutated hands, polar lowres, bad proportions, gross proportions, abdominal stretch, glans, fused fingers, bad body, malnourished,



スポンサーリンク

3.refarence

civitai.com

【Stable Diffusion】YesMixとLoRAでリゼロのエミリア画像を生成してみた

スポンサーリンク

今回はYesMixとLoRAでリゼロのエミリア画像を生成にやってみました
この記事は備忘録になります

目次

スポンサーリンク

この記事でわかること

google colabとdiffusers上でリゼロのエミリア画像を生成する際に使用したモデルとLoRAとプロンプト

1.実行環境

Google Colab
Diffusers transformers==4.26.0
model : YesMix LoRA: Emiria-Re:zero-Re:从零开始的异世界生活-爱蜜莉雅-性感美女-エミリア-Re:ゼロから始める異世界生活-艾米莉娅-Emilia
LoRA:Detail Tweaker LoRA

2.生成結果

positive プロンプト

(transparent_gothic:1.2), aimiliya, cleavage, medium breasts, light smile,best quality, black dress, arms behind back"

negative プロンプト

mutated hands, liquid fingers, bad-hands-5, Painting, sketches, (worst quality:2), (low quality:2), (normal quality:2), ((monochrome:)), ((grayscales)), skin spots, acne, skin blemishes, age spots, (deformity), multiple breasts, (mutated hands and fingers:1.5 ), (long body:1.3), (mutation, poorly drawn:1.2) , bad anatomy, malformed, mutated, anatomical nonsense, QR code, bar code, censored, beard, furry, mosaic, excrement, faeces, shit, extra limbs, low contrast, draft, tiling, fat, big hip, short legs:1.25, fused fingers, twisted legs,  tie, belt, extra arms, extra fingers

seed=8138960370567

seed=8937656145375

seed=11469184407674

スポンサーリンク

3.参考

civitai.com

【Stable Diffusion】Tried AnyLoraCleanLinearMix_ClearVAE which can generate animated images.

スポンサーリンク

I've been experimenting with the Goblin Slayer LoRA and learned that there is a model called AnyLoraCleanLinearMix_ClearVAE.
I'll give it a try as soon as I can.

contents

スポンサーリンク

abstract

What kind of images can be generated using AnyLoraCleanLinearMix_ClearVAE with google colab and dfiffusers

1.requirement

Google Colab
Diffusers transformers==4.26.0
model : AnyLoraCleanLinearMix_ClearVAE

2.result

positive prompt

1girl, parted lips, blush, makeup, light smile, school uniform, classroom, light rays, glow, thighs, collarbone, narrow waist, (masterpiece), wallpaper

negative prompt

EasyNegative, sketch, duplicate, ugly, huge eyes, text, logo, monochrome, worst face, (bad and mutated hands:1.3), (worst quality:2.0), (low quality:2.0), (blurry:2.0), horror, geometry, bad_prompt, (bad hands), (missing fingers), multiple limbs, bad anatomy, (interlocked fingers:1.2), Ugly Fingers, (extra digit and hands and fingers and legs and arms:1.4), crown braid, ((2girl)), (deformed fingers:1.2), (long fingers:1.2),succubus wings,horn,succubus horn,succubus hairstyle, (bad-artist-anime), bad-artist, bad hand, too many hair, cat ears, animal ears

seed=58179784487876

seed=83191336445445

seed=14975731158334

スポンサーリンク

3.refarence

civitai.com

【Stable Diffusion】YesMixとLoRAで五等分の花嫁の中野四葉の画像を生成してみた

スポンサーリンク

今回はYesMixとLoRAで五等分の花嫁の中野四葉の画像生成に挑戦してみました
この記事は備忘録になります

目次

スポンサーリンク

この記事でわかること

google colabとdiffusers上でYesMixとLoRAを使って中野四葉の画像を生成できるか

1.実行環境

Google Colab
Diffusers transformers==4.26.0
model : YesMix LoRA: Nakano Yotsuba 中野四葉 / 5-Toubun no Hanayome
LoRA:Detail Tweaker LoRA

2.生成結果

positive プロンプト

aayotsuba, 1girl, parted lips, blush, makeup, light smile, blue eyes, short hair, hair ribbon, green ribbon, hairband, green bow, sweater vest, blazer, black jacket, long sleeves, green skirt, pleated skirt, classroom, light rays, glow, thighs, collarbone, narrow waist, (masterpiece), wallpaper

negative プロンプト

(worst quality, low quality:1.4), monochrome, zombie, (interlocked fingers:1.2), bad-hands-5, mutated hands, liquid fingers

seed=22953595524279

seed=34296230560728

seed=59705587826985

スポンサーリンク

3.参考

civitai.com

【pytorch】pytorchテンプレートを使った学習環境を作る方法

スポンサーリンク

これまで画像分類モデルの学習をさせる際にpytochのフレームワークのclassyvisionを使っていました
フレームワークは使いやすいのですが、自分で拡張することが難しそうです・・・
フレームワークでなくテンプレートであれば色々拡張できそうでしたので、今回よさそうなテンプレートを探して、試してみました
この記事は備忘録になります

目次

スポンサーリンク

この記事でわかること

pytorchテンプレートを使った学習環境を作る方法

1.環境構築

1.1 実行環境

Jetson Xavier NX
ubuntu18.04
docker
python3.6

1.2 テンプレートの取得

今回使用したテンプレートは以下になります
github.com

以下コマンドでgithubからcloneします

cd workspace
git clone https://github.com/victoresque/pytorch-template.git

1.3 dockerfile&imageの作成

今回使用したdockerfileは以下になります

FROM nvcr.io/nvidia/l4t-pytorch:r32.4.4-pth1.6-py3

RUN pip3 install --upgrade pip
RUN pip3 install --ignore-installed PyYAML
RUN pip3 install tensorboard
RUN pip3 install pandas

こちらをbuildします

sudo docker build . -t pytorch_templete

1.4 docker containerの起動

docker containerを起動して、コンテナ内に入ります

sudo docker run -it --rm --runtime nvidia -v /path/to/your/workspace/dir/:/workspace --workdir /workspace --network host pytorch_templete

2.サンプル実行

今回はmnistとresnetによる画像分類モデルの学習を実行してみます
config.jsonにはデフォルトで上記内容の学習になるように記述されているので、このまま使います

python3 train.py -c config.json

実行後の評価結果は以下のような感じです

    epoch          : 57
    loss           : 0.07924625007832926
    accuracy       : 0.9757558606973595
    top_k_acc      : 0.9974081753554502
    val_loss       : 0.03324085925061731
    val_accuracy   : 0.9901690729483283
    val_top_k_acc  : 0.999501329787234

テンプレートを使った学習ができるようになりました

感想

シンプルな構造のテンプレートなので、拡張しやすそうです

スポンサーリンク

3.参考

github.com

【Stable Diffusion】try to use CetusMix for creteing an animated image generation model

スポンサーリンク

I have recently been experimenting with various models for generating animated images.
Last time I tried Dark Sushi Mix.
This time, I would like to use CetusMix to generate images.

contents

スポンサーリンク

abstract

What kind of images can be generated using CetusMix with google colab and dfiffusers.

1.requirement

Google Colab
Diffusers transformers==4.26.0
model : CetusMix

2.result

positive prompt

1girl, parted lips, blush, makeup, light smile, school uniform, classroom, light rays, glow, thighs, collarbone, narrow waist, (masterpiece), wallpaper

negative prompt

distorted face, badhandv4:0.6, extra fingers, fewer fingers, extra digit, bad hands, bad finger, head cut off, Easy Negative, disfigured, ugly, mutation, deformed, deformed face, long face, cross-eyed, long neck, cross-eyed, mutated hands, polar lowres, bad proportions, gross proportions, abdominal stretch, glans, fused fingers, bad body, malnourished,

seed=8027268520340

seed=9757710301925

seed=12547386801084

スポンサーリンク

3.refarence

civitai.com

4.impression

I had a hard time getting a clean image, probably because the prompts and parameters were not good...
I need to adjust the prompts and parameters.