Download handler.py from jonathanrstern/logo-generator: direct link, hf CLI and curl.
- Browser
- Download file 689 Bytes
-
https://huggingface.co/jonathanrstern/logo-generator/resolve/refs%2Fpr%2F1/handler.py
- Command line
-
hf download hf://jonathanrstern/logo-generator@refs/pr/1/handler.py
-
curl -L -o handler.py https://huggingface.co/jonathanrstern/logo-generator/resolve/refs%2Fpr%2F1/handler.py
689 Bytes
| from typing import Dict, List, Any | |
| from diffusers import ControlNetModel, StableDiffusionControlNetPipeline, StableDiffusionPipeline, DiffusionPipeline | |
| class EndpointHandler(): | |
| def __init__(self, path=""): | |
| self.pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0") | |
| self.pipeline.load_lora_weights(".", weight_name="/repository/safetensors.safetensors") | |
| print('hiiiii') | |
| def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]: | |
| print('data:', data) | |
| input = data['inputs'] | |
| print('input:', input) | |
| result = self.pipeline(input) | |
| print('result:', result) | |
| return result | |