thushalya commited on
Commit
403cb04
1 Parent(s): 861ab00

add os.enviorment

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -16,6 +16,9 @@ import pandas as pd
16
  from transformers import pipeline
17
  from torch.utils.data import Dataset, DataLoader
18
  import torch.nn as nn
 
 
 
19
 
20
 
21
 
@@ -143,6 +146,8 @@ def extract_features(tweet):
143
  # Loading personality model
144
 
145
  def personality_detection(text, threshold=0.05, endpoint= 1.0):
 
 
146
  tokenizer = AutoTokenizer.from_pretrained ("Nasserelsaman/microsoft-finetuned-personality",token=PERSONALITY_TOKEN)
147
  model = AutoModelForSequenceClassification.from_pretrained ("Nasserelsaman/microsoft-finetuned-personality",token=PERSONALITY_TOKEN)
148
 
@@ -368,5 +373,10 @@ def greet(tweet):
368
 
369
  return str(predicted_class)
370
 
371
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
372
- demo.launch()
 
 
 
 
 
 
16
  from transformers import pipeline
17
  from torch.utils.data import Dataset, DataLoader
18
  import torch.nn as nn
19
+ import os
20
+ from dotenv import load_dotenv
21
+ load_dotenv()
22
 
23
 
24
 
 
146
  # Loading personality model
147
 
148
  def personality_detection(text, threshold=0.05, endpoint= 1.0):
149
+ PERSONALITY_TOKEN =os.environ.get('PERSONALITY_TOKEN', None)
150
+ print(PERSONALITY_TOKEN)
151
  tokenizer = AutoTokenizer.from_pretrained ("Nasserelsaman/microsoft-finetuned-personality",token=PERSONALITY_TOKEN)
152
  model = AutoModelForSequenceClassification.from_pretrained ("Nasserelsaman/microsoft-finetuned-personality",token=PERSONALITY_TOKEN)
153
 
 
373
 
374
  return str(predicted_class)
375
 
376
+ # demo = gr.Interface(fn=greet, inputs="text", outputs="text")
377
+ demo = gr.Interface(
378
+ title = "Unmasking Hate: An Integrated Approach to Detecting Hate Speech in Social Media",
379
+ # fn=greet,
380
+ fn=greet, inputs=gr.Textbox(placeholder="Enter an input sentence...",label="Input Sentence"),
381
+ allow_flagging = "never",outputs="text")
382
+ demo.launch()