---
# System prepended metadata

title: OOTDiffusion
tags: [lora]

---

## OOTDiffusion
https://github.com/levihsu/ootdiffusion?tab=readme-ov-file
> DEMO：https://huggingface.co/spaces/levihsu/OOTDiffusion
> 模型：https://huggingface.co/levihsu/OOTDiffusion/tree/main

> 在ComfyUI上安裝OOTDiffusion：https://github.com/AuroBit/ComfyUI-OOTDiffusion
> 在ComfyUI上安裝OOTDiffusio教學影片：https://www.bilibili.com/video/BV1Ew4m1d7Bn/?vd_source=d060fe4dd5a6683127f1df9c93c14b1f

---

#### 在本地執行指令
1. 需在D:\OOTDiffusion\run該路徑下指令(cmd)

2. (半身) python run_ootd.py --model_path D:\OOTDiffusion\run\data\model --cloth_path D:\OOTDiffusion\run\data\cloth --scale 2.0 --sample 1
> -model_path後的路徑為模特的圖片絕對位置
> -cloth_path後的路徑為衣服的圖片絕對位置
> --sample "1" -> 該數字為生產結果的照片張數

3. (全身) python run_ootd.py --model_path D:\OOTDiffusion\run\data\model --cloth_path D:\OOTDiffusion\run\data\cloth --category 1 --scale 2.0 --sample 1
> --model_type 模型的類型
> --category 換服裝的類型(上半身0、下半身1、連身裙2)

* **半身**
![upload_18501f4b65a2562b6c8ade44dd447f07](https://hackmd.io/_uploads/Hkw6x-i90.png)


* **全身**
![upload_151246e08b99a429b9dab5188c4c57c5](https://hackmd.io/_uploads/HJw1-WjcA.png)

> 可以選擇上半身、下半身、連身裙

---

#### 在ComfyUI上開啟
1. 進入目錄
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build
2. cmd指令->vcvars64.bat
3. 進入ComfyUI目錄
D:\ComfyUI\ComfyUI_windows_portable\ComfyUI
4. 執行指令->C:\Users\User\miniconda3\envs\ootd3\python.exe main.py

#### 執行ComfyUI的API檔案
1. 開啟ComfyUI中的Python範例檔案
> 路徑->D:\ComfyUI\ComfyUI_windows_portable\ComfyUI\script_examples
2. 將既有prompt_text那段更改成新的API檔案
3. 執行新的API檔案
> 到路徑->D:\ComfyUI\ComfyUI_windows_portable\ComfyUI\script_examples執行cmd
D:\ComfyUI\ComfyUI_windows_portable\python_miniconda_env\ComfyUI\python.exe comfyui_ootd.py

---

### 結果
* **半身**
![upload_b89771fe8c227e1ba763c3bfac48ee40](https://hackmd.io/_uploads/SJAW-WiqR.jpg)
![upload_95401d1def84367bdabee38317fc96e7](https://hackmd.io/_uploads/HyMfZWoqR.jpg)

* **全身**
> **上半身**
![upload_cc7d9e4ea67f425d9bb5f534ac5dbb6b](https://hackmd.io/_uploads/rkifWWs9C.jpg)

> **下半身**
![upload_501abfdd03917b53e325d36019fff52f](https://hackmd.io/_uploads/rkf7ZZoqA.png)

> **連身裙**
![upload_2a2573110b7a3cc3782e75b66370d5be](https://hackmd.io/_uploads/S1_mbWoc0.png)

---

### 執行API檔案
1. 到try_on路徑(D:\try_on)
![圖片1](https://hackmd.io/_uploads/rk-nY0sv0.png)
2. 點start.bat
3. 開啟連結 http://192.168.8.109:5003/docs
![image](https://hackmd.io/_uploads/r1hmdCiw0.png)
4. {POST}try_on上傳category(衣物類別)和上傳模特/衣服圖片並執行
5. {GET}image輸入結果的id來顯示圖片，要download點選true/false

---

### 對內port改成對外
* 參考 : https://medium.com/%E4%BC%81%E9%B5%9D%E4%B9%9F%E6%87%82%E7%A8%8B%E5%BC%8F%E8%A8%AD%E8%A8%88/%E5%BF%AB%E9%80%9F%E8%AE%93%E5%A4%96%E7%B6%B2%E9%80%A3%E6%8E%A5%E6%9C%AC%E6%A9%9F%E7%9A%84%E5%88%A9%E5%99%A8-ngrok-ac92f792e1f0
1. 登入ngrok
2. ![image](https://hackmd.io/_uploads/Skt9vLCDC.png)
點選Your Authtoken,copy 
3. 在ngrok.exe的路徑開啟cmd
![image](https://hackmd.io/_uploads/SkD8uIRP0.png)
5. ngrok authtoken YOUR_AUTHTOKEN
6. ngrok http <port>
![image](https://hackmd.io/_uploads/ByjtuURwA.png)
網址改為Forwarding+port
    
    
    python run_ootd.py --model_path    "D:\III_GAI_DIY\GenAI\OOTDiffusion\images\half_model\model_1.png" --cloth_path "D:\III_GAI_DIY\GenAI\OOTDiffusion\images\dress\053790_1.jpg" --category 1 --scale 2.0 --sample 1
    
    
# Comfyui
* 換下半身:https://www.bilibili.com/video/BV1ew4m1f7bb/