{"id":33141949,"url":"https://github.com/GINK03/alt-i2v","last_synced_at":"2025-11-20T06:03:04.804Z","repository":{"id":72064779,"uuid":"84396041","full_name":"GINK03/alt-i2v","owner":"GINK03","description":"alternative illustration2vec implitation of sigmoids of fully connected layer","archived":false,"fork":false,"pushed_at":"2017-10-20T11:47:12.000Z","size":149,"stargazers_count":34,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-17T21:48:13.497Z","etag":null,"topics":["deep-learning","keras","multiclass-classification","otaku","vectorization"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GINK03.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-03-09T03:55:06.000Z","updated_at":"2022-04-10T02:33:06.000Z","dependencies_parsed_at":"2024-01-07T18:09:56.255Z","dependency_job_id":null,"html_url":"https://github.com/GINK03/alt-i2v","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GINK03/alt-i2v","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GINK03%2Falt-i2v","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GINK03%2Falt-i2v/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GINK03%2Falt-i2v/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GINK03%2Falt-i2v/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GINK03","download_url":"https://codeload.github.com/GINK03/alt-i2v/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GINK03%2Falt-i2v/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285382190,"owners_count":27162159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-20T02:00:05.334Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","keras","multiclass-classification","otaku","vectorization"],"created_at":"2025-11-15T12:00:48.322Z","updated_at":"2025-11-20T06:03:04.798Z","avatar_url":"https://github.com/GINK03.png","language":"Python","funding_links":[],"categories":["Image Recognition"],"sub_categories":[],"readme":"# Alternative Implementation Of Illustration2Vec Ver2.\n\n## Alternative Illustration2Vec Ver2の概要\n- 画像をタグ等の特定の特徴量に従ってベクトル化できる\n- このベクトルとは通常画像分類で用いられるsoftmaxなどのマルチクラスではなく、softprobの(\\*1)問題として捉えることができる\n\n### Version2の改善、変更点\n- Ver1に比べて探索的であって割とひどいコードを修正して、わかりやすく変えました\n- 150x150の画像のサイズから、224x224にスケールアップしました\n- BatchNormalizationだけでなく、DropOutも併用してネットワークのスパース性を高めました\n- Msgpackを用いたKVSをやめて、ただのPickleで画像のシリアライズをする様になりました\n- Keras V2のインターフェースに合わせました\n\n\\*1 softprobはxgboostの用語でありますが、各クラスに該当するものが、その確率値を返すものです  \n\n## VGG16の転移学習\nVGG16の評価モデルはよくチューニングされており、別段何かしなくても良いパフォーマンスが出せます  \nそのため、VGG16の評価モデルを転移学習することでそのチューニングされた良い状態を保存しつつ、softprobに該当する部分を付け足すことで、illustration2vecに該当する機能を付与させます\n\n## モデル図  \n毎回気持ちですみません（しかし、なんらかの活性化関数の新規のものの提案というスタイルではないので、雑でいいという思いがあります）  \n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/4949982/31811430-7ee4de0a-b5ba-11e7-8bc7-d6749cb4e9cf.png\"\u003e\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e 図1. モデルのイメージ \u003c/div\u003e\n\n## 転移学習時のネットワーク設計\n今回は過去最大の5000次元を予想するというタスクであったので、全結合層をReLuで結合していきます  \n前回はBatchNormalizationのみでやったのですが、これだけを用いうることに少し不安があったので、DropOutを30%のデータを入れるようにしました  \nReLu, DropOutともネットワークを疎結合にする役割が期待できますので、ネットワークの意味のクラスタが獲得しやすくなると期待できます  \n\n## オプティマイザと損失関数\nこれ系のタスクではAdamかSGDが良い成績をいつも収めることが期待されていますので、何も考えず、Adamで決め打ちです  \n- オプティマイザ、Adam : LearningRate 0.001\n- 損失関数、BINARY CROSS ENTROPY\n\n## 使ったデータセット\nSafebooruさんからダウンロードさせていただきました  \nタグとURLと画像の三つの情報を保存し、学習用のデータセット1,500,000枚、テスト様に20,000枚用意します  \n\n## データがメモリに乗り切らないときに使ったアプローチ\nメモリに乗らないときは、最近いつも使うのですが、データセットを分割読み込みまします  \nソフトウェア工学者にとっては一般的なアプローチですが、Epochと対応させて学習すると、なんとかスケジューリングできます(ちゃんとKerasのインターフェースの中にはgeneratorというデータセットを切り出す仕組みがありますが、私はこれを操作が複雑になりすぎると感じているであまり用いていません)  \n\n具体的には、15000枚の画像をオンメモリに保持 -\u003e 1Epoch回す -\u003e 別の150000枚の画像をオンメモリに保持 -\u003e 1Epoch回す -\u003e ...\n  \nということを続けていきます\n\n全てが一回のみスキャンされます\n\n## 転移学習の例\n\n### 前処理\nmake_datapairディレクトリ内のmake_datapair.pyを\"--make_tag_index\"オプションをつけて実行すると、特定のディレクトリの内部の画像とタグ情報に対して、よく頻出するタグ5000個に対して、タグとそのインデックスを記述します  \n\nmake_dataset.pyを\"--make_pair\"のオプションをつけて実行することで、実行することで、タグとインデックスをもとに、画像のベクトル情報 Xとそのタグ情報をベクトル化した情報yのペアを作ります。一つの画像に対して、Piar(X,y)となる情報をpickle形式のファイルで出力します  \n\n### 学習\nalt_i2v_V2.pyに\"--train\"オプションをつけて実行することで、学習します。15000枚の画像のデータセットをラウンドロビンで切り替えながら学習しますが、メモリ64GByteマシンの基準でやっていますので、必要に応じて、サイズを小さくするか、ランダムサンプルに切り替えるか、Epoch数を変化させるなどすると良いでしょう  \n\n### 予想\nalt_i2v_V2.pyに\"--pred\"オプションをつけて実行することで予想が可能です  \n\n\n## 評価\n定量的なMSEの他に、定性的なみんなが好きそうな結果を載せておきます  \n結果は概ね、良好で、画像識別は本当に今や簡単になりましたね、という印象があります  \n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"450px\" src=\"https://user-images.githubusercontent.com/4949982/31794222-77a9fa70-b55c-11e7-8b77-b13f738c7301.png\"\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\" \u003e\n  \u003cimg width=\"350px\" src=\"https://user-images.githubusercontent.com/4949982/31794577-bb07323c-b55d-11e7-9e93-4fb761bda917.png\"\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"450px\" src=\"https://user-images.githubusercontent.com/4949982/31794618-e59cd1fa-b55d-11e7-8d4c-22b1a5b20230.png\"\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"350px\" src=\"https://user-images.githubusercontent.com/4949982/31794847-9c2fdf98-b55e-11e7-84ea-7f6c8551bbf0.png\"\u003e\n\u003c/div\u003e\n\n\n\u003cdiv align=\"center\"\"\u003e\n  \u003cimg width=\"450px\" src=\"https://user-images.githubusercontent.com/4949982/31795198-df56f788-b55f-11e7-924b-01d42f5f4315.png\"\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"350px\" src=\"https://user-images.githubusercontent.com/4949982/31809809-4e4b1ff8-b5b4-11e7-8d58-074804960a32.png\"\u003e\n\u003c/div\u003e\n\n## KPI予想としてのIllustration2Vec\n[Practical Lessons from Predicting Clicks on Ads at Facebook](https://research.fb.com/wp-content/uploads/2016/11/practical-lessons-from-predicting-clicks-on-ads-at-facebook.pdf)という論文があります  \n\n趣旨としては、テキストや画像やなんらかを特徴量の集合としてみなして、CTR予想などのKPI予想問題を行う際、特徴量が極めて高次元である際、アルゴリズム（この場合、勾配ブースティングの木の出力値）を特徴量とすることで、これを元にLinear Regressionをかけることで、より実践的な速度で、より高精度で予想できるという趣旨でした  \n\n勾配ブースティングはそのアルゴリズムから残渣となる誤差を最小化する様に特徴量を選択しますが、例えば、これがIllustration2Vecの出力次元値ではどうでしょうか。アルゴリズムが自動で獲得した粒度の特徴量ではないですが、同様の圧縮された特徴量の空間と見做すことができます。(LDA的な自動でクラスタを獲得させる方法も筋が良さそうです)  \n\nデータが十分に手元にないので、検証は今現在、簡単に行えそうにはありませんが、できそうなことなのでいずれチャレンジしたいと考えています  \n\n## コード\nこちらからダウンロード可能です  \n[https://github.com/GINK03/alt-i2v](https://github.com/GINK03/alt-i2v)\n\n## ライセンス\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGINK03%2Falt-i2v","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGINK03%2Falt-i2v","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGINK03%2Falt-i2v/lists"}