Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
83afffe
1
Parent(s):
a50b0f8
update device
Browse files
app.py
CHANGED
|
@@ -31,7 +31,16 @@ def load_model():
|
|
| 31 |
unet=None,
|
| 32 |
token=token,
|
| 33 |
)
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
return text_pipe
|
| 36 |
|
| 37 |
@spaces.GPU
|
|
|
|
| 31 |
unet=None,
|
| 32 |
token=token,
|
| 33 |
)
|
| 34 |
+
|
| 35 |
+
# Set the execution device to match the text encoder's device
|
| 36 |
+
# This ensures tokenizer outputs go to the correct device
|
| 37 |
+
if hasattr(text_encoder, 'device'):
|
| 38 |
+
text_pipe._execution_device = text_encoder.device
|
| 39 |
+
else:
|
| 40 |
+
# Find the device of the first parameter
|
| 41 |
+
text_pipe._execution_device = next(text_encoder.parameters()).device
|
| 42 |
+
|
| 43 |
+
print(f"Model loaded successfully on device: {text_pipe._execution_device}")
|
| 44 |
return text_pipe
|
| 45 |
|
| 46 |
@spaces.GPU
|