Update handler.py
Browse files- handler.py +12 -7
handler.py
CHANGED
|
@@ -2,14 +2,19 @@ from diffusers import DiffusionPipeline
|
|
| 2 |
import torch
|
| 3 |
|
| 4 |
class EndpointHandler:
|
| 5 |
-
def __init__(self, path=""):
|
| 6 |
print("Loading pipeline...")
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
def __call__(self, data):
|
| 15 |
inputs = data.pop("inputs", data)
|
|
|
|
| 2 |
import torch
|
| 3 |
|
| 4 |
class EndpointHandler:
|
| 5 |
+
def __init__(self, path="Texttra/Cityscape_Studio"):
|
| 6 |
print("Loading pipeline...")
|
| 7 |
+
try:
|
| 8 |
+
self.pipe = DiffusionPipeline.from_pretrained(
|
| 9 |
+
path,
|
| 10 |
+
torch_dtype=torch.float16,
|
| 11 |
+
revision="fp16",
|
| 12 |
+
use_safetensors=True
|
| 13 |
+
).to("cuda")
|
| 14 |
+
print("Pipeline loaded successfully.")
|
| 15 |
+
except Exception as e:
|
| 16 |
+
print(f"Error loading model: {e}")
|
| 17 |
+
raise
|
| 18 |
|
| 19 |
def __call__(self, data):
|
| 20 |
inputs = data.pop("inputs", data)
|