Spaces:
No application file
No application file
Update app (3).py
Browse files- app (3).py +12 -0
app (3).py
CHANGED
@@ -26,6 +26,18 @@ from detectron2.data.detection_utils import convert_PIL_to_numpy,_apply_exif_ori
|
|
26 |
from torchvision.transforms.functional import to_pil_image
|
27 |
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def pil_to_binary_mask(pil_image, threshold=0):
|
30 |
np_image = np.array(pil_image)
|
31 |
grayscale_image = Image.fromarray(np_image).convert("L")
|
|
|
26 |
from torchvision.transforms.functional import to_pil_image
|
27 |
|
28 |
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
zero = torch.Tensor([0]).cuda()
|
33 |
+
print(zero.device) # <-- 'cpu' 🤔
|
34 |
+
|
35 |
+
@spaces.GPU
|
36 |
+
def greet(n):
|
37 |
+
print(zero.device) # <-- 'cuda:0' 🤗
|
38 |
+
return f"Hello {zero + n} Tensor"
|
39 |
+
|
40 |
+
|
41 |
def pil_to_binary_mask(pil_image, threshold=0):
|
42 |
np_image = np.array(pil_image)
|
43 |
grayscale_image = Image.fromarray(np_image).convert("L")
|