Change model precision to float32 for CPU compatibility
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import sys
|
| 2 |
-
sys.path.append('/content/ViTON')
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
from PIL import Image
|
|
@@ -10,13 +10,13 @@ from SegBody import segment_body # Import the segmentation function
|
|
| 10 |
# Check if CUDA is available and set the device accordingly
|
| 11 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 12 |
|
| 13 |
-
# Load models with
|
| 14 |
-
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.
|
| 15 |
pipeline = AutoPipelineForInpainting.from_pretrained(
|
| 16 |
"diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
|
| 17 |
vae=vae,
|
| 18 |
-
torch_dtype=torch.
|
| 19 |
-
variant="
|
| 20 |
use_safetensors=True
|
| 21 |
).to(device) # Ensure it uses the appropriate device (CPU or GPU)
|
| 22 |
|
|
|
|
| 1 |
import sys
|
| 2 |
+
sys.path.append('/content/ViTON') # Ensure the SegBody.py file is on the Python path
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
from PIL import Image
|
|
|
|
| 10 |
# Check if CUDA is available and set the device accordingly
|
| 11 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 12 |
|
| 13 |
+
# Load models with fp32 for CPU compatibility
|
| 14 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float32) # Use float32 for CPU
|
| 15 |
pipeline = AutoPipelineForInpainting.from_pretrained(
|
| 16 |
"diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
|
| 17 |
vae=vae,
|
| 18 |
+
torch_dtype=torch.float32, # Use float32 for CPU
|
| 19 |
+
variant="fp32", # Use fp32 for CPU
|
| 20 |
use_safetensors=True
|
| 21 |
).to(device) # Ensure it uses the appropriate device (CPU or GPU)
|
| 22 |
|