Giter VIP home page Giter VIP logo

pastepicture2wallpaper's Introduction

PastePicture2Wallpaper

キャラクターをUbuntu風の壁紙に貼り付けるプログラム。

0. 画像を用意する

お好きな画像を用意してください。

アニメ画像などのわりと対象物と背景がはっきりしているものがおすすめです。

StableDiffusionを使う場合

StableDiffusionを使用して画像を作成することができます。

要件

  • 8GB以上のVRAMが搭載されたGPU(Colabだとそれ以上必要な場合あり)
  • Ubuntu22.04 + Python3.10環境

StableDiffusionの環境構築手順に従って環境構築してください。モデルはanything-v4.0(別途ダウンロード必須)がおすすめです。

作成例

  • ロボットは背景と誤認されやすい。背景を生成させずに線画抽出のみにするとよい。
  • 輪郭がはっきりしないパーツは欠けやすい


1. 画像をColabで深度画像に変換する

PastePicture2Wallpaper.ipynb (Colaboratry)をチェックしてください。


全て実行すると線画がresult.pngという名前でそのまま出力されます。ステップ2に進んでください。


Colabでは、OSの雰囲気に合わせて線の色を変更できます。

  • Mac風(灰色):パステルカラーの背景に合わせて半透明の灰色線画を出力
  • Mac風(白色):鮮やかな背景に半透明の白線画を出力
  • Windows風: 水色の背景にさらに明るい水色半透明の線画を出力
  • Ubuntu風: 紫-桃色の背景に馴染む桃色半透明の線画を出力


画像を閾値を指定して距離を指定(出力画像がうまく深度を捉えられていない場合)

Colabでは画像を見ながら閾値調整と確認が同時にできないので、最も下のコードセルのコメントアウトを外してdepth_result.pngをダウンロードして以下の手順を行います。

画像を閾値を指定して距離を指定

深度閾値が150で適当でない場合、リアルタイムで確認しながら閾値調整できます。


PyQtの使い方下手過ぎて申し訳ないです…

convert.pyを用いて深度の閾値を変更します。デフォルトでは150なので、そのままconvertionボタンを押してもOKです。

オプション

  • -i : 画像パス
  • -d : depth_result.pngを指定

画像は同じサイズにしてください(何も変換しなければ問題無いです)

python3 convert.py -i ~/Downloads/image.jpg -d ~/Downloads/depth_result.png

変換終了後に次のファイルがコマンド入力をしたディレクトリに出力されます。

  • edges_check.jpg : エッジ検出後の画像(確認用)
  • edges.png : エッジ検出後の合成用画像。線に少し透明度があり、背景が透過されています。

残念ながら完璧な線画は出力できないので、適宜修正してください。


2. Gimpなどを使って合成

壁紙をGimpやPowerPointなどで作ってください。


記事


参考

https://axross-recipe.com/recipes/404 by Kazuhito00

pastepicture2wallpaper's People

Contributors

ar-ray-code avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.