Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,8 +73,11 @@ model_tf.load("MentalHealthChatBotmodel.tflearn")
|
|
| 73 |
pytorch_model = PyTorchModel(vocab_size, embedding_dim, hidden_dim, num_classes)
|
| 74 |
|
| 75 |
# Load weights from the TensorFlow model
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
| 78 |
pytorch_model.state_dict()[pytorch_layer_name].copy_(torch.tensor(weights))
|
| 79 |
|
| 80 |
# Move the model to the CPU
|
|
@@ -246,9 +249,9 @@ with gr.Blocks() as demo:
|
|
| 246 |
if emotion == 'joy':
|
| 247 |
return "You're feeling happy! Keep up the great mood!\nUseful Resources:\n[Relaxation Techniques](https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation)\n[Dealing with Stress](https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety)\n[Emotional Wellness Toolkit](https://www.nih.gov/health-information/emotional-wellness-toolkit)\n\nRelaxation Videos:\n[Watch on YouTube](https://youtu.be/m1vaUGtyo-A)"
|
| 248 |
elif emotion == 'anger':
|
| 249 |
-
return "You're feeling angry. It's okay to feel this way. Let's try to calm down.\nUseful Resources:\n[Emotional
|
| 250 |
elif emotion == 'fear':
|
| 251 |
-
return "You're feeling fearful. Take a moment to breathe and relax.\nUseful Resources:\n[Mindfulness Practices](https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation)\n[Coping with Anxiety](https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety)\n[Emotional
|
| 252 |
elif emotion == 'sadness':
|
| 253 |
return "You're feeling sad. It's okay to take a break.\nUseful Resources:\n[Emotional Wellness Toolkit](https://www.nih.gov/health-information/emotional-wellness-toolkit)\n[Dealing with Anxiety](https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety)\n\nRelaxation Videos:\n[Watch on YouTube](https://youtu.be/-e-4Kx5px_I)"
|
| 254 |
elif emotion == 'surprise':
|
|
|
|
| 73 |
pytorch_model = PyTorchModel(vocab_size, embedding_dim, hidden_dim, num_classes)
|
| 74 |
|
| 75 |
# Load weights from the TensorFlow model
|
| 76 |
+
layer_names = ['fc1/kernel', 'fc1/bias', 'fc2/kernel', 'fc2/bias']
|
| 77 |
+
|
| 78 |
+
for layer_name in layer_names:
|
| 79 |
+
weights = model_tf.get_weights(layer_name)
|
| 80 |
+
pytorch_layer_name = layer_name.replace('/', '_')
|
| 81 |
pytorch_model.state_dict()[pytorch_layer_name].copy_(torch.tensor(weights))
|
| 82 |
|
| 83 |
# Move the model to the CPU
|
|
|
|
| 249 |
if emotion == 'joy':
|
| 250 |
return "You're feeling happy! Keep up the great mood!\nUseful Resources:\n[Relaxation Techniques](https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation)\n[Dealing with Stress](https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety)\n[Emotional Wellness Toolkit](https://www.nih.gov/health-information/emotional-wellness-toolkit)\n\nRelaxation Videos:\n[Watch on YouTube](https://youtu.be/m1vaUGtyo-A)"
|
| 251 |
elif emotion == 'anger':
|
| 252 |
+
return "You're feeling angry. It's okay to feel this way. Let's try to calm down.\nUseful Resources:\n[Emotional Wellness Toolkit](https://www.nih.gov/health-information/emotional-wellness-toolkit)\n[Stress Management Tips](https://www.health.harvard.edu/health-a-to-z)\n[Dealing with Anger](https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety)\n\nRelaxation Videos:\n[Watch on YouTube](https://youtu.be/MIc299Flibs)"
|
| 253 |
elif emotion == 'fear':
|
| 254 |
+
return "You're feeling fearful. Take a moment to breathe and relax.\nUseful Resources:\n[Mindfulness Practices](https://www.helpguide.org/mental-health/meditation/mindful-breathing-meditation)\n[Coping with Anxiety](https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety)\n[Emotional Wellness Toolkit](https://www.nih.gov/health-information/emotional-wellness-toolkit)\n\nRelaxation Videos:\n[Watch on YouTube](https://youtu.be/yGKKz185M5o)"
|
| 255 |
elif emotion == 'sadness':
|
| 256 |
return "You're feeling sad. It's okay to take a break.\nUseful Resources:\n[Emotional Wellness Toolkit](https://www.nih.gov/health-information/emotional-wellness-toolkit)\n[Dealing with Anxiety](https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety)\n\nRelaxation Videos:\n[Watch on YouTube](https://youtu.be/-e-4Kx5px_I)"
|
| 257 |
elif emotion == 'surprise':
|