Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,9 +7,7 @@ import tflearn
|
|
| 7 |
import gradio as gr
|
| 8 |
import requests
|
| 9 |
import torch
|
| 10 |
-
import pandas as pd
|
| 11 |
import folium
|
| 12 |
-
from bs4 import BeautifulSoup
|
| 13 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 14 |
from nltk.tokenize import word_tokenize
|
| 15 |
from nltk.stem.lancaster import LancasterStemmer
|
|
@@ -203,12 +201,10 @@ def generate_map(wellness_data):
|
|
| 203 |
icon=folium.Icon(color='blue', icon='info-sign')
|
| 204 |
).add_to(m)
|
| 205 |
|
| 206 |
-
# Save map as an HTML
|
| 207 |
-
|
| 208 |
-
m.save(map_file)
|
| 209 |
|
| 210 |
-
|
| 211 |
-
return map_file
|
| 212 |
|
| 213 |
# Gradio interface setup for user interaction
|
| 214 |
def user_interface(message, location, history, api_key, words, labels, model):
|
|
@@ -226,13 +222,14 @@ def user_interface(message, location, history, api_key, words, labels, model):
|
|
| 226 |
wellness_data = get_wellness_professionals(location, api_key)
|
| 227 |
|
| 228 |
# Generate the map
|
| 229 |
-
|
| 230 |
|
| 231 |
# Create a DataFrame for the suggestions
|
| 232 |
suggestions_df = pd.DataFrame(resources, columns=["Subject", "Article URL"])
|
| 233 |
suggestions_df["Video URL"] = video_link # Add video URL column
|
|
|
|
| 234 |
|
| 235 |
-
return history, history, sentiment, emotion,
|
| 236 |
|
| 237 |
# Load data and model
|
| 238 |
try:
|
|
@@ -257,7 +254,7 @@ location_input = gr.Textbox(label="Enter your location (latitude,longitude)", pl
|
|
| 257 |
|
| 258 |
# Gradio interface definition
|
| 259 |
demo = gr.Interface(
|
| 260 |
-
fn=lambda message, location, history: user_interface(message, location, history, GOOGLE_API_KEY, words, labels, model),
|
| 261 |
inputs=[
|
| 262 |
gr.Textbox(label="Message"),
|
| 263 |
location_input,
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
import requests
|
| 9 |
import torch
|
|
|
|
| 10 |
import folium
|
|
|
|
| 11 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 12 |
from nltk.tokenize import word_tokenize
|
| 13 |
from nltk.stem.lancaster import LancasterStemmer
|
|
|
|
| 201 |
icon=folium.Icon(color='blue', icon='info-sign')
|
| 202 |
).add_to(m)
|
| 203 |
|
| 204 |
+
# Save map as an HTML string
|
| 205 |
+
map_html = m._repr_html_()
|
|
|
|
| 206 |
|
| 207 |
+
return map_html
|
|
|
|
| 208 |
|
| 209 |
# Gradio interface setup for user interaction
|
| 210 |
def user_interface(message, location, history, api_key, words, labels, model):
|
|
|
|
| 222 |
wellness_data = get_wellness_professionals(location, api_key)
|
| 223 |
|
| 224 |
# Generate the map
|
| 225 |
+
map_html = generate_map(wellness_data)
|
| 226 |
|
| 227 |
# Create a DataFrame for the suggestions
|
| 228 |
suggestions_df = pd.DataFrame(resources, columns=["Subject", "Article URL"])
|
| 229 |
suggestions_df["Video URL"] = video_link # Add video URL column
|
| 230 |
+
suggestions_html = suggestions_df.to_html(escape=False)
|
| 231 |
|
| 232 |
+
return history, history, sentiment, emotion, suggestions_html, map_html
|
| 233 |
|
| 234 |
# Load data and model
|
| 235 |
try:
|
|
|
|
| 254 |
|
| 255 |
# Gradio interface definition
|
| 256 |
demo = gr.Interface(
|
| 257 |
+
fn=lambda message, location, history: user_interface(message, location, history, os.getenv("GOOGLE_API_KEY"), words, labels, model),
|
| 258 |
inputs=[
|
| 259 |
gr.Textbox(label="Message"),
|
| 260 |
location_input,
|