CaioMartins1 commited on
Commit
6366ef3
·
1 Parent(s): 917b452

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -3,15 +3,16 @@ from transformers import pipeline
3
  from datasets import load_dataset
4
 
5
  # Load the dataset
6
- dataset = load_dataset("ziq/depression_advice")
 
7
 
8
  # Load the model
9
  model_name = "mrm8488/distilroberta-base-finetuned-suicide-depression"
10
  qa_pipeline = pipeline("question-answering", model=model_name)
11
 
12
  # Extract context and messages
13
- contexts = dataset["train"]["context"]
14
- messages = dataset["train"]["text"]
15
 
16
  # Define a function to generate answers
17
  def generate_answer(messages):
@@ -19,7 +20,7 @@ def generate_answer(messages):
19
  results = qa_pipeline(question=messages, context=contexts)
20
 
21
  # Return the first answer
22
- return results["answer"][0] if results["answer"] else "No answer found."
23
 
24
  # Create a Gradio interface
25
  iface = gr.Interface(
 
3
  from datasets import load_dataset
4
 
5
  # Load the dataset
6
+ advice_dataset = load_dataset("ziq/depression_advice")
7
+ depression_dataset = load_dataset("ShreyaR/DepressionDetection")
8
 
9
  # Load the model
10
  model_name = "mrm8488/distilroberta-base-finetuned-suicide-depression"
11
  qa_pipeline = pipeline("question-answering", model=model_name)
12
 
13
  # Extract context and messages
14
+ contexts = advice_dataset["train"]["text"]
15
+ messages = depression_dataset["train"]["text"]
16
 
17
  # Define a function to generate answers
18
  def generate_answer(messages):
 
20
  results = qa_pipeline(question=messages, context=contexts)
21
 
22
  # Return the first answer
23
+ return results["answer"] if results["answer"] else "No answer found."
24
 
25
  # Create a Gradio interface
26
  iface = gr.Interface(