buelfhood commited on
Commit
5bb9f19
·
verified ·
1 Parent(s): 9ee27c4

Update app to have the single trained adapter

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -1,10 +1,7 @@
1
  import gradio as gr
2
  import re
3
- from transformers import AutoTokenizer
4
  from adapters import AutoAdapterModel
5
- from transformers import TextClassificationPipeline
6
- import gradio as gr
7
- from transformers import pipeline
8
 
9
  def preprocess(issue):
10
  issue = re.sub(r'```.*?```', ' ', issue, flags=re.DOTALL)
@@ -18,7 +15,7 @@ def preprocess(issue):
18
  def text_classification(text):
19
  tokenizer = AutoTokenizer.from_pretrained("FacebookAI/roberta-base", max_length=256, truncation=True, padding="max_length")
20
  model = AutoAdapterModel.from_pretrained("FacebookAI/roberta-base")
21
- adapter_react = model.load_adapter("buelfhood/irc-facebook-react", source = "hf",set_active=True)
22
  classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer, max_length=256, padding="max_length", truncation=True,top_k=None)
23
  preprocessed_issue = preprocess (text)
24
  out = classifier(preprocessed_issue)[0]
@@ -31,9 +28,7 @@ io = gr.Interface(fn=text_classification,
31
  inputs= gr.Textbox(lines=20, label="Text", placeholder="Enter title here..."),
32
  outputs="label",
33
  title="Issue Report Classification",
34
- description="Enter a text of an issue and see whether it is a bug, enhancement or question?",
35
  examples=examples)
36
 
37
- io.launch(share=True)
38
-
39
-
 
1
  import gradio as gr
2
  import re
3
+ from transformers import AutoTokenizer,TextClassificationPipeline
4
  from adapters import AutoAdapterModel
 
 
 
5
 
6
  def preprocess(issue):
7
  issue = re.sub(r'```.*?```', ' ', issue, flags=re.DOTALL)
 
15
  def text_classification(text):
16
  tokenizer = AutoTokenizer.from_pretrained("FacebookAI/roberta-base", max_length=256, truncation=True, padding="max_length")
17
  model = AutoAdapterModel.from_pretrained("FacebookAI/roberta-base")
18
+ adapter_react = model.load_adapter("buelfhood/irc-single-adapter", source = "hf",set_active=True)
19
  classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer, max_length=256, padding="max_length", truncation=True,top_k=None)
20
  preprocessed_issue = preprocess (text)
21
  out = classifier(preprocessed_issue)[0]
 
28
  inputs= gr.Textbox(lines=20, label="Text", placeholder="Enter title here..."),
29
  outputs="label",
30
  title="Issue Report Classification",
31
+ description="Enter a text of an issue and see whether it is a bug, feature or question?",
32
  examples=examples)
33
 
34
+ io.launch(share=True)