Update handler.py
Browse files- handler.py +4 -0
handler.py
CHANGED
@@ -26,6 +26,8 @@ class EndpointHandler:
|
|
26 |
model.hf_device_map["upsample"] = model.hf_device_map["swin2sr.embeddings"]
|
27 |
self.model = Swin2SRForImageSuperResolution.from_pretrained("caidas/swin2SR-classical-sr-x2-64", device_map=model.hf_device_map)
|
28 |
|
|
|
|
|
29 |
def __call__(self, data: Any):
|
30 |
"""
|
31 |
Args:
|
@@ -39,6 +41,8 @@ class EndpointHandler:
|
|
39 |
inputs = self.processor(image, return_tensors="pt")
|
40 |
with torch.no_grad():
|
41 |
outputs = self.model(**inputs)
|
|
|
|
|
42 |
|
43 |
output = outputs.reconstruction.data.squeeze().float().cpu().clamp_(0, 1).numpy()
|
44 |
output = np.moveaxis(output, source=0, destination=-1)
|
|
|
26 |
model.hf_device_map["upsample"] = model.hf_device_map["swin2sr.embeddings"]
|
27 |
self.model = Swin2SRForImageSuperResolution.from_pretrained("caidas/swin2SR-classical-sr-x2-64", device_map=model.hf_device_map)
|
28 |
|
29 |
+
print(subprocess.run(["nvidia-smi"]))
|
30 |
+
|
31 |
def __call__(self, data: Any):
|
32 |
"""
|
33 |
Args:
|
|
|
41 |
inputs = self.processor(image, return_tensors="pt")
|
42 |
with torch.no_grad():
|
43 |
outputs = self.model(**inputs)
|
44 |
+
|
45 |
+
print(subprocess.run(["nvidia-smi"]))
|
46 |
|
47 |
output = outputs.reconstruction.data.squeeze().float().cpu().clamp_(0, 1).numpy()
|
48 |
output = np.moveaxis(output, source=0, destination=-1)
|