Pendrokar commited on
Commit
8e4d744
1 Parent(s): 2c5d591

examples; auto

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -1,11 +1,11 @@
1
  import gradio as gr
2
  import torch
3
- from transformers import pipeline, AutoTokenizer, DistilBertForSequenceClassification
4
 
5
  modelName = "Pendrokar/TorchMoji"
6
 
7
  distil_tokenizer = AutoTokenizer.from_pretrained(modelName)
8
- distil_model = DistilBertForSequenceClassification.from_pretrained(modelName, problem_type="multi_label_classification")
9
 
10
  pipeline = pipeline(task="text-classification", model=distil_model, tokenizer=distil_tokenizer)
11
 
@@ -13,7 +13,19 @@ def predict(deepmoji_analysis):
13
  predictions = pipeline(deepmoji_analysis)
14
  return deepmoji_analysis, {p["label"]: p["score"] for p in predictions}
15
 
16
- gradio_app = gr.Interface(fn=predict, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  if __name__ == "__main__":
19
  gradio_app.launch()
 
1
  import gradio as gr
2
  import torch
3
+ from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification, DistilBertForSequenceClassification
4
 
5
  modelName = "Pendrokar/TorchMoji"
6
 
7
  distil_tokenizer = AutoTokenizer.from_pretrained(modelName)
8
+ distil_model = AutoModelForSequenceClassification.from_pretrained(modelName, problem_type="multi_label_classification")
9
 
10
  pipeline = pipeline(task="text-classification", model=distil_model, tokenizer=distil_tokenizer)
11
 
 
13
  predictions = pipeline(deepmoji_analysis)
14
  return deepmoji_analysis, {p["label"]: p["score"] for p in predictions}
15
 
16
+ gradio_app = gr.Interface(
17
+ fn=predict,
18
+ inputs="text",
19
+ outputs="text"
20
+ verbose=True,
21
+ examples=[
22
+ "This GOT show just remember LOTR times!",
23
+ "Man, can't believe that my 30 days of training just got a NaN loss",
24
+ "I couldn't see 3 Tom Hollands coming...",
25
+ "There is nothing better than a soul-warming coffee in the morning",
26
+ "I fear the vanishing gradient", "deberta"
27
+ ]
28
+ )
29
 
30
  if __name__ == "__main__":
31
  gradio_app.launch()