yangfan commited on
Commit
a9e3801
·
1 Parent(s): 6bce1f7

feat(*): change evn

Browse files
Files changed (3) hide show
  1. app.py +14 -3
  2. packages.txt +0 -0
  3. requirements.txt +2 -0
app.py CHANGED
@@ -1,7 +1,18 @@
1
  import gradio as gr
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
7
  demo.launch()
 
 
 
1
  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="text", outputs="text")
14
+
15
+ demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
16
  demo.launch()
17
+
18
+
packages.txt ADDED
File without changes
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ scikit-learn