Spaces:
Sleeping
Sleeping
Commit
Β·
f0585ee
1
Parent(s):
4317393
Updated app
Browse files
app.py
CHANGED
@@ -6,18 +6,17 @@ from PIL import Image
|
|
6 |
import requests
|
7 |
from transformers import DetrImageProcessor
|
8 |
|
|
|
9 |
|
10 |
zero = torch.Tensor([0]).cuda()
|
11 |
print(zero.device) # <-- 'cpu' π€
|
12 |
|
13 |
@spaces.GPU
|
14 |
-
def
|
15 |
-
processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
|
16 |
-
|
17 |
encoding = processor(image, return_tensors='pt')
|
18 |
print(encoding.keys())
|
19 |
print(zero.device) # <-- 'cuda:0' π€
|
20 |
-
return f"Hello {
|
21 |
|
22 |
-
demo = gr.Interface(fn=
|
23 |
demo.launch()
|
|
|
6 |
import requests
|
7 |
from transformers import DetrImageProcessor
|
8 |
|
9 |
+
processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
|
10 |
|
11 |
zero = torch.Tensor([0]).cuda()
|
12 |
print(zero.device) # <-- 'cpu' π€
|
13 |
|
14 |
@spaces.GPU
|
15 |
+
def detect(image):
|
|
|
|
|
16 |
encoding = processor(image, return_tensors='pt')
|
17 |
print(encoding.keys())
|
18 |
print(zero.device) # <-- 'cuda:0' π€
|
19 |
+
return f"Hello {encoding.keys()} Tensor"
|
20 |
|
21 |
+
demo = gr.Interface(fn=detect, inputs=gr.Image(label="Input image", type="pil"), outputs=gr.Image(label="Output image", type="pil"))
|
22 |
demo.launch()
|