Upload handler.py
Browse files- handler.py +5 -5
handler.py
CHANGED
|
@@ -5,10 +5,10 @@ from diffusers import FluxPipeline, FluxTransformer2DModel, AutoencoderKL, Torch
|
|
| 5 |
from PIL.Image import Image
|
| 6 |
import torch
|
| 7 |
|
| 8 |
-
import torch._dynamo
|
| 9 |
-
torch._dynamo.config.suppress_errors = True
|
| 10 |
|
| 11 |
-
|
| 12 |
|
| 13 |
def compile_pipeline(pipe) -> Any:
|
| 14 |
pipe.transformer.fuse_qkv_projections()
|
|
@@ -18,7 +18,7 @@ def compile_pipeline(pipe) -> Any:
|
|
| 18 |
|
| 19 |
class EndpointHandler:
|
| 20 |
def __init__(self, path="NoMoreCopyright/FLUX.1-dev-test"):
|
| 21 |
-
is_compile =
|
| 22 |
#repo_id = "camenduru/FLUX.1-dev-diffusers"
|
| 23 |
repo_id = "NoMoreCopyright/FLUX.1-dev-test"
|
| 24 |
dtype = torch.bfloat16
|
|
@@ -31,7 +31,7 @@ class EndpointHandler:
|
|
| 31 |
|
| 32 |
@torch.inference_mode()
|
| 33 |
def __call__(self, data: Dict[str, Any]) -> Image:
|
| 34 |
-
|
| 35 |
|
| 36 |
if "inputs" in data and isinstance(data["inputs"], str):
|
| 37 |
prompt = data.pop("inputs")
|
|
|
|
| 5 |
from PIL.Image import Image
|
| 6 |
import torch
|
| 7 |
|
| 8 |
+
#import torch._dynamo
|
| 9 |
+
#torch._dynamo.config.suppress_errors = True
|
| 10 |
|
| 11 |
+
from huggingface_inference_toolkit.logging import logger
|
| 12 |
|
| 13 |
def compile_pipeline(pipe) -> Any:
|
| 14 |
pipe.transformer.fuse_qkv_projections()
|
|
|
|
| 18 |
|
| 19 |
class EndpointHandler:
|
| 20 |
def __init__(self, path="NoMoreCopyright/FLUX.1-dev-test"):
|
| 21 |
+
is_compile = False
|
| 22 |
#repo_id = "camenduru/FLUX.1-dev-diffusers"
|
| 23 |
repo_id = "NoMoreCopyright/FLUX.1-dev-test"
|
| 24 |
dtype = torch.bfloat16
|
|
|
|
| 31 |
|
| 32 |
@torch.inference_mode()
|
| 33 |
def __call__(self, data: Dict[str, Any]) -> Image:
|
| 34 |
+
logger.info(f"Received incoming request with {data=}")
|
| 35 |
|
| 36 |
if "inputs" in data and isinstance(data["inputs"], str):
|
| 37 |
prompt = data.pop("inputs")
|