abdulmatinomotoso commited on
Commit
48632ad
1 Parent(s): ab5cfc6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -10,7 +10,7 @@ import torch
10
  labels = ["Explicit", "Not_Explicit"]
11
 
12
  #Defining the models and tokenuzer
13
- model_name = 'valurank/finetuned-distilbert-explicit_content_detection'
14
  model = AutoModelForSequenceClassification.from_pretrained(model_name)
15
  tokenizer = AutoTokenizer.from_pretrained(model_name)
16
 
@@ -35,8 +35,8 @@ def clean_text(url):
35
  " +", " ", text
36
  ).strip() # get rid of multiple spaces and replace with a single
37
 
38
- text = re.sub(r'Date\s\d{1,2}\/\d{1,2}\/\d{4}', '', text) #remove date
39
- text = re.sub(r'\d{1,2}:\d{2}\s[A-Z]+\s[A-Z]+', '', text) #remove time
40
 
41
  return text
42
 
@@ -44,7 +44,7 @@ def clean_text(url):
44
  def get_category(file):
45
  text = clean_text(file)
46
 
47
- input_tensor = tokenizer.encode(text, return_tensors='pt', truncation=True)
48
  logits = model(input_tensor).logits
49
 
50
  softmax = torch.nn.Softmax(dim=1)
@@ -56,10 +56,10 @@ def get_category(file):
56
  return emotion
57
 
58
  #Creating the interface for the radio app
59
- demo = gr.Interface(get_category, inputs=gr.inputs.Textbox(label='Drop your articles here'),
60
- outputs = 'text',
61
- title='Explicit Content Detection')
62
 
63
  #Launching the gradio app
64
- if __name__ == '__main__':
65
  demo.launch(debug=True)
 
10
  labels = ["Explicit", "Not_Explicit"]
11
 
12
  #Defining the models and tokenuzer
13
+ model_name = "valurank/finetuned-distilbert-explicit_content_detection"
14
  model = AutoModelForSequenceClassification.from_pretrained(model_name)
15
  tokenizer = AutoTokenizer.from_pretrained(model_name)
16
 
 
35
  " +", " ", text
36
  ).strip() # get rid of multiple spaces and replace with a single
37
 
38
+ text = re.sub(r"Date\s\d{1,2}\/\d{1,2}\/\d{4}", "", text) #remove date
39
+ text = re.sub(r"\d{1,2}:\d{2}\s[A-Z]+\s[A-Z]+", "", text) #remove time
40
 
41
  return text
42
 
 
44
  def get_category(file):
45
  text = clean_text(file)
46
 
47
+ input_tensor = tokenizer.encode(text, return_tensors="pt", truncation=True)
48
  logits = model(input_tensor).logits
49
 
50
  softmax = torch.nn.Softmax(dim=1)
 
56
  return emotion
57
 
58
  #Creating the interface for the radio app
59
+ demo = gr.Interface(get_category, inputs=gr.inputs.Textbox(label="Drop your articles here"),
60
+ outputs = "text",
61
+ title="Explicit Content Detection")
62
 
63
  #Launching the gradio app
64
+ if __name__ == "__main__":
65
  demo.launch(debug=True)