kd01
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # waifu2x - AI 圖像縮放和圖像降噪程式 ## 簡介 waifu2x是一個用於動漫風格圖像的圖像縮放和圖像降噪程式,也支援處理普通圖片。 waifu2x的核心是一個用於超解析度成像的卷積神經網路(SRCNN)。它使用了NVIDIA CUDA技術,但也有使用OpenCL和Vulkan的替代實現。 https://zh.wikipedia.org/wiki/Waifu2x ## 下載 **waifu2x ncnn Vulkan** https://github.com/nihui/waifu2x-ncnn-vulkan ## 使用說明 **基本用法** waifu2x-ncnn-vulkan -i infile -o outfile [options]... **選項說明** -h 顯示說明 -v 詳細輸出 -i input-path 設定輸入路徑,可為檔案路徑或目錄。 -o output-path 設定輸入路徑,可為檔案路徑或目錄路徑。 -n noise-level 設定降噪等級,-1/0/1/2/3, 預設為0。等級越高效果越強,-1=不降噪。 -s scale 設定縮放等級,1/2, 預設為2。1 為不縮放,2 為兩倍。 -t tile-size 設定分塊大小,>=32/0皆為自動, 預設為0。使用較小的值來減少 GPU 記憶體使用,預設值為自動。 -m model-path 設定模型路徑,預設為models-cunet,位於程式目錄下的資料夾 (models-*),用來針對不同類型的圖片,models-cunet: 一般圖片,models-upconv_7_anime_style_art_rgb: 插畫,models-upconv_7_photo: 照片。 -g gpu-id 使用 GPU,預設為0。可用 0,1,2 對於多 GPU。 -j load:proc:save 三階段執行續數量 (圖片解碼 + waifu2x 放大 + 圖片編碼)。預設為 1:2:2,使用較大的值可能增加 GPU 使用率與消耗更多 GPU 記憶體。對於小尺寸圖片可用 4:4:4,而大尺寸圖片可用 2:2:2,預設值通常對於大多數情況都不錯。如果發現 GPU 負載很低,則嘗試增加執行續數量以加快處裡。 -x 啟用 tta 模式 -f format 設定輸出格式 (png/webp, 預設為ext/png),對於 png 格式的支援性較好,webp 編碼輸出的檔案則較小,以上兩者皆為無損。 ## 應用 ### 圖片放大與降噪 將 input.jpg 放大2倍、降噪強度2,儲存為 output.jpg ```powershell waifu2x-ncnn-vulkan -v -i input.jpg -o output.jpg -n 2 -s 2 ``` 處理 intputdir 目錄下的所有圖片,儲存至 outputdir 目錄下 ```powershell waifu2x-ncnn-vulkan -v -i intputdir -o outputdir -n 2 -s 2 ``` ### 影片放大與降噪 由於 waifu2x 不支援影片格式輸入,必須先將影片轉換成連續圖片再用 waifu2x 處理圖片,由於是作為暫時的檔案,建議使用無損格式。最後將處理過的圖片轉成影片,再與片源音訊重新封裝合成新的影片檔即可。以下示範使用 ffmpeg 將影片轉換成圖片再轉回影片。 > 注意,CMD 中使用 %% 表示 %。 基本用法 ffmpeg [options for input] -i inputfile [options for output] outputfile **前置步驟** 由於將影片轉成連續會流失以下訊息: * 顯示寬高比 (Display Aspect Ratio) * 影格速率 (Frame Rate) * 像素格式 (Pixel Format) 檢查 input.mpg 內容: ```powershell ffmpeg -hide_banner -i input.mpg ``` 從主控台輸出訊息找到視訊串流的規格,例如下列這樣: ```text Stream #0:0: Video: mpeg2video, yuv420p, 704x480 [SAR 40:33 DAR 16:9], 24000/1001 fps ``` 記錄下所需的訊息,yuv420p、DAR 16:9、24000/1001 fps,之後會用到。 **影片轉換成連續圖片** 為了方便之後將連續圖片轉換成影片,使用 `-r` 轉換輸出 fps 為為固定不變的 fps 即 CFR。輸出檔名 `%07d` 為圖片的編號,由 0 起始,往前補 0 為 7 位數。 ```powershell ffmpeg -i input.mpg -r 24000/1001 -f image2 "frames_original\%07d.png" ``` 由於 `yuv420p` 與 png 不相容,ffmpeg 將自動轉換成其他合適格式,以及 png 不支援非 1:1 的 SAR,將輸出錯誤的 DAR (顯示比例): `704x480 [SAR 1:1 DAR 44:30]`。因此,之後將圖片轉回影片時可使用 `-pix_fmt` 與 `-aspect` 選項,來轉換像素格式與強制指定顯示比例。 **放大圖片** 將 frames_original 目錄下的所有圖片放大降噪處理後輸出到 frames_scaled 目錄 ```powershell waifu2x-ncnn-vulkan -v -i frames_original -o frames_scaled -n 2 -s 2 ``` 輸入圖片 704x480 將得到 png 影像規格為 `rgb24, 1408x960 [SAR 1:1 DAR 44:30]` 的圖片,由於 1408x960不是標準解析度,若想得到符合標準解析度的寬或高,之後使用 ffmpeg 將圖片轉回影片時利用 `-s` 選項再次縮放畫面。 **連續圖片轉換成影片** 輸入是連續圖片檔必須使用 `-r` 來強制指定正確的輸入 fps;使用 `-pix_fmt` 轉換像素格式與片源相同;使用 `-aspect` 修正錯誤的顯示比例。對 input.mpg 使用 `-vn` 禁用影像,並使用 `-c:a copy` 複製音訊。1408x960 不是標準解析度,可用 `-s` 縮放輸出解析度到標準規格。 將 frames_scaled 目錄下的 PNG 圖片轉換成影片 ```powershell ffmpeg -f image2 -r 24000/1001 -i "frames_scaled\%07d.png" -vn -i input.mpg -s 1280x720 -c:v libx264 -refs:v 5 -preset:v slower -crf:v 18 -pix_fmt yuv420p -aspect 16/9 -c:a copy output.mkv ``` **分段處裡** 由於一次將整個影片輸出為圖片,將得到數量龐大的檔案數量,這對硬碟是不小的負擔。為了減輕硬碟的壓力,可以使用 `-ss` 與 `-t` 指定開始與持續時間將一個片段影片輸出為連續圖片。 ```powershell ffmpeg -i input.mpg -ss 00:00:00 -t 60 -r 24 -f image2 frames_original/%6d.png ``` ```powershell waifu2x-ncnn-vulkan -v -i frames_original -o frames_scaled -n 2 -s 2 ``` ```powershell ffmpeg -f image2 -r 24000/1001 -i "frames_scaled\%6d.png" -s 1280x720 -c:v libx264 -refs:v 5 -preset:v slower -crf:v 18 -pix_fmt yuv420p -aspect 16/9 clips\000.mkv ``` 假設影片長度為 00:24:35,重複以上步驟並使用不同的時間點得到多個分段影片。 `-i input.mpg -ss 00:01:00 -t 60` -> png files -> 001.mkv `-i input.mpg -ss 00:02:00 -t 60` -> png files -> 002.mkv `-i input.mpg -ss 00:03:00 -t 60` -> png files -> 003.mkv 中間省略...... `-i input.mpg -ss 00:24:00` -> png files -> 024.mkv 以上會得到 000.mkv ... 024.mkv,共 25個影片檔。將所有分段影片的檔名或完整路徑儲存為utf8編碼的純文字文件。 clipslist.txt ```text file '000.mkv' file '001.mkv' file '002.mkv' 中間省略...... file '024.mkv' ``` 串連所有分段影片並與片源音訊重新封裝合成新影片 ```powershell ffmpeg -f concat -safe 0 -i clipslist.txt -vn -i input.mpg -c copy output.mkv ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully