danieldux commited on
Commit
b0b048d
1 Parent(s): 5abb6ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -1,17 +1,30 @@
1
  import os
2
  import gradio as gr
3
  import spaces
 
4
  import torch
5
 
6
  zero = torch.Tensor([0]).cuda()
7
  print(zero.device) # <-- 'cpu' 🤔
8
 
 
 
 
 
 
 
 
9
  @spaces.GPU
10
- def greet(n):
11
- print(zero.device) # <-- 'cuda:0' 🤗
12
- return f"Hello {zero + n} Tensor"
13
 
14
- # demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text())
15
- # demo.launch()
16
- token = os.getenv("HF_TOKEN")
17
- gr.load("models/ICILS/xlm-r-icils-ilo", hf_token=token).launch()
 
 
 
 
 
 
 
1
  import os
2
  import gradio as gr
3
  import spaces
4
+ from transformers import pipeline
5
  import torch
6
 
7
  zero = torch.Tensor([0]).cuda()
8
  print(zero.device) # <-- 'cpu' 🤔
9
 
10
+ token = os.getenv("HF_TOKEN")
11
+ # gr.load("models/ICILS/xlm-r-icils-ilo", hf_token=token).launch()
12
+
13
+ # Load the pre-trained model
14
+ classifier = pipeline("text-classification", model="ICILS/xlm-r-icils-ilo", hf_token=token)
15
+
16
+ # Define the prediction function
17
  @spaces.GPU
18
+ def classify_text(text):
19
+ return classifier(text)[0]
 
20
 
21
+ # Create the Gradio interface
22
+ demo = gr.Interface(
23
+ fn=classify_text,
24
+ inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
25
+ outputs=gr.Text(),
26
+ title="XLM-R ISCO classification with ZeroGPU",
27
+ description="Classify occupations using a pre-trained XLM-R-ISCO model on Hugging Face Spaces with ZeroGPU"
28
+ )
29
+
30
+ demo.launch()