KheemDH commited on
Commit
745a201
Β·
1 Parent(s): 025e47c

Change model precision to float32 for CPU compatibility

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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 fp16 variant for GPU compatibility
14
- vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
15
  pipeline = AutoPipelineForInpainting.from_pretrained(
16
  "diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
17
  vae=vae,
18
- torch_dtype=torch.float16, # Use fp16 for GPU
19
- variant="fp16", # Ensure you are using fp16 for GPU
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