Update handler.py
Browse files- handler.py +2 -8
handler.py
CHANGED
|
@@ -3,20 +3,14 @@ import torch
|
|
| 3 |
|
| 4 |
class EndpointHandler:
|
| 5 |
def __init__(self, model_dir: str):
|
| 6 |
-
# Load the pipeline strictly from your repo files
|
| 7 |
self.pipe = DiffusionPipeline.from_pretrained(
|
| 8 |
model_dir,
|
| 9 |
-
custom_pipeline="pipeline_wan_i2v",
|
| 10 |
torch_dtype=torch.float16,
|
| 11 |
-
|
| 12 |
).to("cuda")
|
| 13 |
|
| 14 |
def __call__(self, data):
|
| 15 |
-
# Expecting the input: {"image": <base64 or URL or HF file>}
|
| 16 |
image = data["image"]
|
| 17 |
-
|
| 18 |
-
# Run the model
|
| 19 |
result = self.pipe(image)
|
| 20 |
-
|
| 21 |
-
# The pipeline returns frames of the generated video
|
| 22 |
return {"video": result.frames}
|
|
|
|
| 3 |
|
| 4 |
class EndpointHandler:
|
| 5 |
def __init__(self, model_dir: str):
|
|
|
|
| 6 |
self.pipe = DiffusionPipeline.from_pretrained(
|
| 7 |
model_dir,
|
| 8 |
+
custom_pipeline="pipeline_wan_i2v",
|
| 9 |
torch_dtype=torch.float16,
|
| 10 |
+
safety_checker=None
|
| 11 |
).to("cuda")
|
| 12 |
|
| 13 |
def __call__(self, data):
|
|
|
|
| 14 |
image = data["image"]
|
|
|
|
|
|
|
| 15 |
result = self.pipe(image)
|
|
|
|
|
|
|
| 16 |
return {"video": result.frames}
|