Spaces:
Runtime error
Runtime error
Commit ·
438430f
0
Parent(s):
Duplicate from awacke1/Google-Maps-Web-Service-Py
Browse filesCo-authored-by: Aaron C Wacker <awacke1@users.noreply.huggingface.co>
- .gitattributes +36 -0
- README.md +33 -0
- US.txt +0 -0
- app.py +185 -0
- maps-platform-101-webgl.zip +3 -0
- node-v18.13.0-x64.msi +3 -0
- nvm-setup.exe +3 -0
- requirements.txt +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
node-v18.13.0-x64.msi filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
nvm-setup.exe filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: GMaps-Geocode-Gradio-Lat-Lon
|
| 3 |
+
emoji: 🌍Map
|
| 4 |
+
colorFrom: gray
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 3.16.2
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
duplicated_from: awacke1/Google-Maps-Web-Service-Py
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
Naming Scheme:
|
| 14 |
+
3D-GLB-Aframe-GoogleAPI-Map programs on Gradio could be named as "Gradio3DMap" or "GradioMap3D".
|
| 15 |
+
|
| 16 |
+
Ontology:
|
| 17 |
+
Gradio3DMap or GradioMap3D can be categorized as a type of mapping software that utilizes three-dimensional GLB models to display geographical data on a map. These programs are built using A-Frame, a web framework for building virtual reality experiences, and integrated with GoogleAPI to provide location-based services.
|
| 18 |
+
|
| 19 |
+
The ontology for Gradio3DMap or GradioMap3D can be further broken down into subcategories, such as:
|
| 20 |
+
|
| 21 |
+
Data Visualization: These programs can be used to visualize and analyze complex geospatial data in a three-dimensional format, making it easier for users to understand and interpret the information.
|
| 22 |
+
|
| 23 |
+
Real-time Data Updates: Gradio3DMap or GradioMap3D can be used to display real-time updates for various data, such as weather, traffic, and other live events.
|
| 24 |
+
|
| 25 |
+
Interactive User Interface: The software can be built with interactive user interfaces that allow users to interact with the map and its elements, such as panning, zooming, and rotating the 3D model.
|
| 26 |
+
|
| 27 |
+
Cross-Platform Compatibility: Gradio3DMap or GradioMap3D can be built to run on multiple platforms, such as desktops, smartphones, and tablets, making it accessible to a wide range of users.
|
| 28 |
+
|
| 29 |
+
Customization: The software can be customized to fit specific user requirements and business needs. This includes adding custom markers, colors, and other visual elements to the map.
|
| 30 |
+
|
| 31 |
+
Integration with other APIs: Gradio3DMap or GradioMap3D can be integrated with other APIs, such as social media APIs, to provide additional functionality, such as real-time feeds of social media data.
|
| 32 |
+
|
| 33 |
+
Overall, Gradio3DMap or GradioMap3D is a powerful mapping software that provides an immersive and interactive way to visualize and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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import googlemaps
|
| 2 |
+
import os
|
| 3 |
+
#GM_TOKEN=os.environ.get("GM_TOKEN") # Get Google Maps Token Here: https://console.cloud.google.com/google/maps-apis/
|
| 4 |
+
|
| 5 |
+
from datetime import datetime
|
| 6 |
+
|
| 7 |
+
# googlemaps_TOKEN = os.environ.get("googlemaps_TOKEN")
|
| 8 |
+
# gmaps = googlemaps.Client(key=googlemaps_TOKEN)
|
| 9 |
+
gmaps = googlemaps.Client(key='AIzaSyDybq2mxujekZVivmr03Y5-GGHXesn4TLI')
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def GetMapInfo(inputText):
|
| 13 |
+
#geocode_result = gmaps.geocode('640 Jackson Street, St. Paul, MN 55101')
|
| 14 |
+
geocode_result = gmaps.geocode(inputText)
|
| 15 |
+
|
| 16 |
+
geo_address = geocode_result[0]['formatted_address']
|
| 17 |
+
geo_directions = geocode_result[0]['geometry']['location']
|
| 18 |
+
geo_geocode = geocode_result[0]['geometry']['location_type']
|
| 19 |
+
|
| 20 |
+
lat = geo_directions['lat']
|
| 21 |
+
lng = geo_directions['lng']
|
| 22 |
+
|
| 23 |
+
reverse_geocode_result = gmaps.reverse_geocode((lat, lng))
|
| 24 |
+
|
| 25 |
+
now = datetime.now()
|
| 26 |
+
directions_result = gmaps.directions("Sydney Town Hall","Parramatta, NSW",mode="transit", departure_time=now)
|
| 27 |
+
#addressvalidation_result = gmaps.addressvalidation(['1600 Amphitheatre Pk'], regionCode='US', locality='Mountain View', enableUspsCass=True)
|
| 28 |
+
|
| 29 |
+
#return geocode_result, reverse_geocode_result, directions_result, addressvalidation_result
|
| 30 |
+
#return geo_address, geo_directions, geo_geocode, reverse_geocode_result, directions_result, addressvalidation_result
|
| 31 |
+
return geo_address, geo_directions, geo_geocode
|
| 32 |
+
|
| 33 |
+
from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
|
| 34 |
+
import torch
|
| 35 |
+
import gradio as gr
|
| 36 |
+
from datasets import load_dataset
|
| 37 |
+
|
| 38 |
+
# PersistDataset -----
|
| 39 |
+
import os
|
| 40 |
+
import csv
|
| 41 |
+
from gradio import inputs, outputs
|
| 42 |
+
import huggingface_hub
|
| 43 |
+
from huggingface_hub import Repository, hf_hub_download, upload_file
|
| 44 |
+
from datetime import datetime
|
| 45 |
+
|
| 46 |
+
#fastapi is where its at: share your app, share your api
|
| 47 |
+
import fastapi
|
| 48 |
+
|
| 49 |
+
from typing import List, Dict
|
| 50 |
+
import httpx
|
| 51 |
+
import pandas as pd
|
| 52 |
+
import datasets as ds
|
| 53 |
+
|
| 54 |
+
UseMemory=True
|
| 55 |
+
HF_TOKEN=os.environ.get("HF_TOKEN")
|
| 56 |
+
|
| 57 |
+
def SaveResult(text, outputfileName):
|
| 58 |
+
basedir = os.path.dirname(__file__)
|
| 59 |
+
savePath = outputfileName
|
| 60 |
+
print("Saving: " + text + " to " + savePath)
|
| 61 |
+
from os.path import exists
|
| 62 |
+
file_exists = exists(savePath)
|
| 63 |
+
if file_exists:
|
| 64 |
+
with open(outputfileName, "a") as f: #append
|
| 65 |
+
f.write(str(text.replace("\n"," ")))
|
| 66 |
+
f.write('\n')
|
| 67 |
+
else:
|
| 68 |
+
with open(outputfileName, "w") as f: #write
|
| 69 |
+
f.write(str("time, message, text\n")) # one time only to get column headers for CSV file
|
| 70 |
+
f.write(str(text.replace("\n"," ")))
|
| 71 |
+
f.write('\n')
|
| 72 |
+
return
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def store_message(name: str, message: str, outputfileName: str):
|
| 76 |
+
basedir = os.path.dirname(__file__)
|
| 77 |
+
savePath = outputfileName
|
| 78 |
+
|
| 79 |
+
# if file doesnt exist, create it with labels
|
| 80 |
+
from os.path import exists
|
| 81 |
+
file_exists = exists(savePath)
|
| 82 |
+
|
| 83 |
+
if (file_exists==False):
|
| 84 |
+
with open(savePath, "w") as f: #write
|
| 85 |
+
f.write(str("time, message, text\n")) # one time only to get column headers for CSV file
|
| 86 |
+
if name and message:
|
| 87 |
+
writer = csv.DictWriter(f, fieldnames=["time", "message", "name"])
|
| 88 |
+
writer.writerow(
|
| 89 |
+
{"time": str(datetime.now()), "message": message.strip(), "name": name.strip() }
|
| 90 |
+
)
|
| 91 |
+
df = pd.read_csv(savePath)
|
| 92 |
+
df = df.sort_values(df.columns[0],ascending=False)
|
| 93 |
+
else:
|
| 94 |
+
if name and message:
|
| 95 |
+
with open(savePath, "a") as csvfile:
|
| 96 |
+
writer = csv.DictWriter(csvfile, fieldnames=[ "time", "message", "name", ])
|
| 97 |
+
writer.writerow(
|
| 98 |
+
{"time": str(datetime.now()), "message": message.strip(), "name": name.strip() }
|
| 99 |
+
)
|
| 100 |
+
df = pd.read_csv(savePath)
|
| 101 |
+
df = df.sort_values(df.columns[0],ascending=False)
|
| 102 |
+
return df
|
| 103 |
+
|
| 104 |
+
mname = "facebook/blenderbot-400M-distill"
|
| 105 |
+
model = BlenderbotForConditionalGeneration.from_pretrained(mname)
|
| 106 |
+
tokenizer = BlenderbotTokenizer.from_pretrained(mname)
|
| 107 |
+
|
| 108 |
+
def take_last_tokens(inputs, note_history, history):
|
| 109 |
+
if inputs['input_ids'].shape[1] > 128:
|
| 110 |
+
inputs['input_ids'] = torch.tensor([inputs['input_ids'][0][-128:].tolist()])
|
| 111 |
+
inputs['attention_mask'] = torch.tensor([inputs['attention_mask'][0][-128:].tolist()])
|
| 112 |
+
note_history = ['</s> <s>'.join(note_history[0].split('</s> <s>')[2:])]
|
| 113 |
+
history = history[1:]
|
| 114 |
+
return inputs, note_history, history
|
| 115 |
+
|
| 116 |
+
def add_note_to_history(note, note_history):# good example of non async since we wait around til we know it went okay.
|
| 117 |
+
note_history.append(note)
|
| 118 |
+
note_history = '</s> <s>'.join(note_history)
|
| 119 |
+
return [note_history]
|
| 120 |
+
|
| 121 |
+
title = "💬ChatBack🧠💾"
|
| 122 |
+
description = """Chatbot With persistent memory dataset allowing multiagent system AI to access a shared dataset as memory pool with stored interactions.
|
| 123 |
+
Current Best SOTA Chatbot: https://huggingface.co/facebook/blenderbot-400M-distill?text=Hey+my+name+is+ChatBack%21+Are+you+ready+to+rock%3F """
|
| 124 |
+
|
| 125 |
+
def get_base(filename):
|
| 126 |
+
basedir = os.path.dirname(__file__)
|
| 127 |
+
print(basedir)
|
| 128 |
+
#loadPath = basedir + "\\" + filename # works on windows
|
| 129 |
+
loadPath = basedir + filename # works on ubuntu
|
| 130 |
+
print(loadPath)
|
| 131 |
+
return loadPath
|
| 132 |
+
|
| 133 |
+
def chat(message, history):
|
| 134 |
+
history = history or []
|
| 135 |
+
if history:
|
| 136 |
+
history_useful = ['</s> <s>'.join([str(a[0])+'</s> <s>'+str(a[1]) for a in history])]
|
| 137 |
+
else:
|
| 138 |
+
history_useful = []
|
| 139 |
+
|
| 140 |
+
history_useful = add_note_to_history(message, history_useful)
|
| 141 |
+
inputs = tokenizer(history_useful, return_tensors="pt")
|
| 142 |
+
inputs, history_useful, history = take_last_tokens(inputs, history_useful, history)
|
| 143 |
+
reply_ids = model.generate(**inputs)
|
| 144 |
+
response = tokenizer.batch_decode(reply_ids, skip_special_tokens=True)[0]
|
| 145 |
+
history_useful = add_note_to_history(response, history_useful)
|
| 146 |
+
list_history = history_useful[0].split('</s> <s>')
|
| 147 |
+
history.append((list_history[-2], list_history[-1]))
|
| 148 |
+
|
| 149 |
+
df=pd.DataFrame()
|
| 150 |
+
|
| 151 |
+
if UseMemory:
|
| 152 |
+
#outputfileName = 'ChatbotMemory.csv'
|
| 153 |
+
outputfileName = 'ChatbotMemory3.csv' # Test first time file create
|
| 154 |
+
df = store_message(message, response, outputfileName) # Save to dataset
|
| 155 |
+
basedir = get_base(outputfileName)
|
| 156 |
+
|
| 157 |
+
return history, df, basedir
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
with gr.Blocks() as demo:
|
| 163 |
+
gr.Markdown("<h1><center>🍰 AI Google Maps Demonstration🎨</center></h1>")
|
| 164 |
+
|
| 165 |
+
with gr.Row():
|
| 166 |
+
t1 = gr.Textbox(lines=1, default="", label="Chat Text:")
|
| 167 |
+
b1 = gr.Button("Respond and Retrieve Messages")
|
| 168 |
+
b2 = gr.Button("Get Map Information")
|
| 169 |
+
|
| 170 |
+
with gr.Row(): # inputs and buttons
|
| 171 |
+
s1 = gr.State([])
|
| 172 |
+
df1 = gr.Dataframe(wrap=True, max_rows=1000, overflow_row_behaviour= "paginate")
|
| 173 |
+
with gr.Row(): # inputs and buttons
|
| 174 |
+
file = gr.File(label="File")
|
| 175 |
+
s2 = gr.Markdown()
|
| 176 |
+
with gr.Row():
|
| 177 |
+
df21 = gr.Textbox(lines=4, default="", label="Geocode1:")
|
| 178 |
+
df22 = gr.Textbox(lines=4, default="", label="Geocode2:")
|
| 179 |
+
df23 = gr.Textbox(lines=4, default="", label="Geocode3:")
|
| 180 |
+
df3 = gr.Dataframe(wrap=True, max_rows=1000, overflow_row_behaviour= "paginate")
|
| 181 |
+
df4 = gr.Dataframe(wrap=True, max_rows=1000, overflow_row_behaviour= "paginate")
|
| 182 |
+
b1.click(fn=chat, inputs=[t1, s1], outputs=[s1, df1, file])
|
| 183 |
+
b2.click(fn=GetMapInfo, inputs=[t1], outputs=[df21, df22, df23])
|
| 184 |
+
|
| 185 |
+
demo.launch(debug=True, show_error=True)
|
maps-platform-101-webgl.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:20a00a3b480707c027b7210f1bfa50e5f3f5b2633f730780f8a6a21073f1b81d
|
| 3 |
+
size 21490518
|
node-v18.13.0-x64.msi
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:248f975c8e93f1eed659c4b8603eb2ea9ab09c6174f02444b85fa33c7ea4cf0f
|
| 3 |
+
size 30941184
|
nvm-setup.exe
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:925a577a97e0fe0ab7d93b295e6d0b690d83a3a5b0e7c1204360fc8712401b6c
|
| 3 |
+
size 5474488
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
googlemaps
|
| 2 |
+
transformers
|
| 3 |
+
torch
|