sergiopaniego commited on
Commit
4317393
β€’
1 Parent(s): d0f5a61

Updated space

Browse files
Files changed (2) hide show
  1. app.py +11 -2
  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(n):
 
 
 
 
10
  print(zero.device) # <-- 'cuda:0' πŸ€—
11
  return f"Hello {zero + n} Tensor"
12
 
13
- demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
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