Commit
•
9701c1e
1
Parent(s):
2ac680c
Upload 2 files
Browse files- handler.py +28 -0
- requirements.txt +192 -0
handler.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
|
3 |
+
import base64
|
4 |
+
from io import BytesIO
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
class EndpointHandler():
|
8 |
+
def __init__(self, path=""):
|
9 |
+
model_id = "timbrooks/instruct-pix2pix"
|
10 |
+
self.pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None)
|
11 |
+
self.pipe.to("cuda")
|
12 |
+
self.pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(self.pipe.scheduler.config)
|
13 |
+
|
14 |
+
def __call__(self, data):
|
15 |
+
|
16 |
+
image=data.pop("image",data)
|
17 |
+
prompt=data.pop("prompt",data).decode('utf-8')
|
18 |
+
image=base64.b64decode(image)
|
19 |
+
raw_images = Image.open(BytesIO(image)).convert('RGB')
|
20 |
+
|
21 |
+
images = self.pipe(prompt, image=raw_images, num_inference_steps=25, image_guidance_scale=1).images
|
22 |
+
return images[0]
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
if __name__=="__main__":
|
27 |
+
my_handler=EndpointHandler(path='.')
|
28 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
absl-py==1.4.0
|
2 |
+
accelerate==0.18.0
|
3 |
+
addict==2.4.0
|
4 |
+
aiohttp==3.8.4
|
5 |
+
aiosignal==1.3.1
|
6 |
+
antlr4-python3-runtime==4.9.3
|
7 |
+
appdirs==1.4.4
|
8 |
+
asteroid==0.6.0
|
9 |
+
asteroid-filterbanks==0.4.0
|
10 |
+
asttokens==2.2.1
|
11 |
+
async-timeout==4.0.2
|
12 |
+
attrs==23.1.0
|
13 |
+
audioread==3.0.0
|
14 |
+
backcall==0.2.0
|
15 |
+
basicsr==1.4.2
|
16 |
+
cached-property==1.5.2
|
17 |
+
cachetools==5.3.0
|
18 |
+
certifi==2022.12.7
|
19 |
+
cffi==1.15.1
|
20 |
+
charset-normalizer==3.1.0
|
21 |
+
ci-sdr==0.0.2
|
22 |
+
click==8.1.3
|
23 |
+
cmake==3.26.3
|
24 |
+
comm==0.1.3
|
25 |
+
ConfigArgParse==1.5.3
|
26 |
+
controlnet-aux==0.0.1
|
27 |
+
ctc-segmentation==1.7.4
|
28 |
+
Cython==0.29.34
|
29 |
+
datasets==2.11.0
|
30 |
+
debugpy==1.6.7
|
31 |
+
decorator==5.1.1
|
32 |
+
diffusers==0.15.0.dev0
|
33 |
+
dill==0.3.6
|
34 |
+
Distance==0.1.3
|
35 |
+
editdistance==0.6.2
|
36 |
+
einops==0.6.1
|
37 |
+
espnet==202301
|
38 |
+
espnet-model-zoo==0.1.7
|
39 |
+
espnet-tts-frontend==0.0.3
|
40 |
+
executing==1.2.0
|
41 |
+
fast-bss-eval==0.1.3
|
42 |
+
filelock==3.12.0
|
43 |
+
Flask==2.2.3
|
44 |
+
Flask-Cors==3.0.10
|
45 |
+
frozenlist==1.3.3
|
46 |
+
fsspec==2023.4.0
|
47 |
+
future==0.18.3
|
48 |
+
g2p-en==2.1.0
|
49 |
+
google-auth==2.17.3
|
50 |
+
google-auth-oauthlib==1.0.0
|
51 |
+
grpcio==1.54.0
|
52 |
+
h5py==3.8.0
|
53 |
+
huggingface-hub==0.13.4
|
54 |
+
humanfriendly==10.0
|
55 |
+
hydra-core==1.3.2
|
56 |
+
HyperPyYAML==1.2.0
|
57 |
+
idna==3.4
|
58 |
+
imageio==2.27.0
|
59 |
+
importlib-metadata==4.9.0
|
60 |
+
importlib-resources==5.12.0
|
61 |
+
inflect==6.0.4
|
62 |
+
ipykernel==6.22.0
|
63 |
+
ipython==8.12.0
|
64 |
+
itsdangerous==2.1.2
|
65 |
+
jaconv==0.3.4
|
66 |
+
jamo==0.4.1
|
67 |
+
jedi==0.18.2
|
68 |
+
Jinja2==3.1.2
|
69 |
+
joblib==1.2.0
|
70 |
+
julius==0.2.7
|
71 |
+
jupyter-client==8.2.0
|
72 |
+
jupyter-core==5.3.0
|
73 |
+
kaldiio==2.18.0
|
74 |
+
lazy-loader==0.2
|
75 |
+
librosa==0.10.0.post2
|
76 |
+
lightning-utilities==0.8.0
|
77 |
+
lit==16.0.1
|
78 |
+
llvmlite==0.39.1
|
79 |
+
lmdb==1.4.1
|
80 |
+
Markdown==3.4.3
|
81 |
+
MarkupSafe==2.1.2
|
82 |
+
matplotlib-inline==0.1.6
|
83 |
+
mir-eval==0.7
|
84 |
+
mpmath==1.3.0
|
85 |
+
msgpack==1.0.5
|
86 |
+
multidict==6.0.4
|
87 |
+
multiprocess==0.70.14
|
88 |
+
nest-asyncio==1.5.6
|
89 |
+
networkx==3.1
|
90 |
+
nltk==3.8.1
|
91 |
+
numba==0.56.4
|
92 |
+
numpy==1.23.0
|
93 |
+
nvidia-cublas-cu11==11.10.3.66
|
94 |
+
nvidia-cuda-cupti-cu11==11.7.101
|
95 |
+
nvidia-cuda-nvrtc-cu11==11.7.99
|
96 |
+
nvidia-cuda-runtime-cu11==11.7.99
|
97 |
+
nvidia-cudnn-cu11==8.5.0.96
|
98 |
+
nvidia-cufft-cu11==10.9.0.58
|
99 |
+
nvidia-curand-cu11==10.2.10.91
|
100 |
+
nvidia-cusolver-cu11==11.4.0.1
|
101 |
+
nvidia-cusparse-cu11==11.7.4.91
|
102 |
+
nvidia-nccl-cu11==2.14.3
|
103 |
+
nvidia-nvtx-cu11==11.7.91
|
104 |
+
oauthlib==3.2.2
|
105 |
+
omegaconf==2.3.0
|
106 |
+
opencv-python==4.7.0.72
|
107 |
+
opt-einsum==3.3.0
|
108 |
+
packaging==23.1
|
109 |
+
pandas==2.0.0
|
110 |
+
parso==0.8.3
|
111 |
+
pb-bss-eval==0.0.2
|
112 |
+
pesq==0.0.4
|
113 |
+
pexpect==4.8.0
|
114 |
+
pickleshare==0.7.5
|
115 |
+
Pillow==9.5.0
|
116 |
+
platformdirs==3.2.0
|
117 |
+
pooch==1.6.0
|
118 |
+
prompt-toolkit==3.0.38
|
119 |
+
protobuf==3.20.1
|
120 |
+
psutil==5.9.5
|
121 |
+
ptyprocess==0.7.0
|
122 |
+
pure-eval==0.2.2
|
123 |
+
pyarrow==11.0.0
|
124 |
+
pyasn1==0.5.0
|
125 |
+
pyasn1-modules==0.3.0
|
126 |
+
pycparser==2.21
|
127 |
+
pydantic==1.10.7
|
128 |
+
pyDeprecate==0.3.2
|
129 |
+
pydub==0.25.1
|
130 |
+
Pygments==2.15.1
|
131 |
+
pypinyin==0.44.0
|
132 |
+
pystoi==0.3.3
|
133 |
+
pytesseract==0.3.10
|
134 |
+
python-dateutil==2.8.2
|
135 |
+
pytorch-lightning==2.0.1.post0
|
136 |
+
pytorch-ranger==0.1.1
|
137 |
+
pytorch-wpe==0.0.1
|
138 |
+
pytz==2023.3
|
139 |
+
PyWavelets==1.4.1
|
140 |
+
pyworld==0.3.3
|
141 |
+
PyYAML==6.0
|
142 |
+
pyzmq==25.0.2
|
143 |
+
regex==2023.3.23
|
144 |
+
requests==2.28.2
|
145 |
+
requests-oauthlib==1.3.1
|
146 |
+
responses==0.18.0
|
147 |
+
rsa==4.9
|
148 |
+
ruamel.yaml==0.17.21
|
149 |
+
ruamel.yaml.clib==0.2.7
|
150 |
+
scikit-image==0.20.0
|
151 |
+
scikit-learn==1.2.2
|
152 |
+
scipy==1.9.0
|
153 |
+
sentencepiece==0.1.98
|
154 |
+
six==1.16.0
|
155 |
+
soundfile==0.12.1
|
156 |
+
soxr==0.3.5
|
157 |
+
speechbrain==0.5.14
|
158 |
+
stack-data==0.6.2
|
159 |
+
sympy==1.11.1
|
160 |
+
tb-nightly==2.13.0a20230422
|
161 |
+
tensorboard-data-server==0.7.0
|
162 |
+
tensorboard-plugin-wit==1.8.1
|
163 |
+
threadpoolctl==3.1.0
|
164 |
+
tifffile==2023.4.12
|
165 |
+
tiktoken==0.3.3
|
166 |
+
timm==0.6.13
|
167 |
+
tokenizers==0.13.3
|
168 |
+
tomli==2.0.1
|
169 |
+
torch==2.0.0
|
170 |
+
torch-complex==0.4.3
|
171 |
+
torch-optimizer==0.1.0
|
172 |
+
torch-stoi==0.1.2
|
173 |
+
torchaudio==2.0.1
|
174 |
+
torchmetrics==0.7.3
|
175 |
+
torchvision==0.15.1
|
176 |
+
tornado==6.3.1
|
177 |
+
tqdm==4.65.0
|
178 |
+
traitlets==5.9.0
|
179 |
+
transformers==4.28.0.dev0
|
180 |
+
triton==2.0.0
|
181 |
+
typeguard==2.13.3
|
182 |
+
typing-extensions==4.5.0
|
183 |
+
tzdata==2023.3
|
184 |
+
Unidecode==1.3.6
|
185 |
+
urllib3==1.26.15
|
186 |
+
waitress==2.1.2
|
187 |
+
wcwidth==0.2.6
|
188 |
+
Werkzeug==2.2.3
|
189 |
+
xxhash==3.2.0
|
190 |
+
yapf==0.33.0
|
191 |
+
yarl==1.9.1
|
192 |
+
zipp==3.15.0
|