Spaces:
Sleeping
Sleeping
sergiopaniego
commited on
Commit
β’
4317393
1
Parent(s):
d0f5a61
Updated space
Browse files- app.py +11 -2
- requirements.txt +3 -0
app.py
CHANGED
@@ -2,13 +2,22 @@ import gradio as gr
|
|
2 |
import spaces
|
3 |
import torch
|
4 |
|
|
|
|
|
|
|
|
|
|
|
5 |
zero = torch.Tensor([0]).cuda()
|
6 |
print(zero.device) # <-- 'cpu' π€
|
7 |
|
8 |
@spaces.GPU
|
9 |
-
def greet(
|
|
|
|
|
|
|
|
|
10 |
print(zero.device) # <-- 'cuda:0' π€
|
11 |
return f"Hello {zero + n} Tensor"
|
12 |
|
13 |
-
demo = gr.Interface(fn=greet, inputs=gr.
|
14 |
demo.launch()
|
|
|
2 |
import spaces
|
3 |
import torch
|
4 |
|
5 |
+
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 greet(image):
|
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 {zero + n} Tensor"
|
21 |
|
22 |
+
demo = gr.Interface(fn=greet, inputs=gr.Image(label="Input image", type="pil"), outputs=gr.Image(label="Output image", type="pil"))
|
23 |
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
timm
|
3 |
+
torch
|