Spaces:
Sleeping
Sleeping
umm-maybe
commited on
Commit
·
5f079a9
1
Parent(s):
41d1888
Pyvis attempt
Browse files- app.py +17 -3
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -1,9 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import json
|
|
|
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
# Load the pipeline
|
| 5 |
tourModel = pipeline(model="manhan/GPT-Tour")
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def getTour(income,size,years,sex,edu,wrk):
|
| 8 |
# person = a dict with person-level and hh-level attributes:
|
| 9 |
person = {}
|
|
@@ -68,7 +80,8 @@ def getTour(income,size,years,sex,edu,wrk):
|
|
| 68 |
print(e)
|
| 69 |
else:
|
| 70 |
print("Nothing extracted!")
|
| 71 |
-
|
|
|
|
| 72 |
|
| 73 |
with gr.Interface(fn=getTour, inputs=[
|
| 74 |
gr.inputs.Textbox(label="Annual Household Income (in dollars)"),
|
|
@@ -76,6 +89,7 @@ with gr.Interface(fn=getTour, inputs=[
|
|
| 76 |
gr.inputs.Textbox(label="Traveler Age (years)"),
|
| 77 |
gr.inputs.Dropdown(["unknown", "male", "female"], label="Gender/sex"),
|
| 78 |
gr.inputs.Dropdown(["unknown", "grade school","highschool", "associates", "bachelors", "graduate"], label="Educational attainment level"),
|
| 79 |
-
gr.inputs.Dropdown(["unknown", "yes","no"], label="Worker status")
|
| 80 |
-
|
|
|
|
| 81 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import json
|
| 3 |
+
from pyvis.network import Network
|
| 4 |
+
|
| 5 |
from transformers import pipeline
|
| 6 |
# Load the pipeline
|
| 7 |
tourModel = pipeline(model="manhan/GPT-Tour")
|
| 8 |
|
| 9 |
+
def vizTour(activityList):
|
| 10 |
+
net = Network(directed=True)
|
| 11 |
+
net.add_node(activityList[0])
|
| 12 |
+
for activity in activityList[1:]:
|
| 13 |
+
if activity not in net.get_nodes():
|
| 14 |
+
net.add_node(activity)
|
| 15 |
+
net.add_edge(activityList[0], activity)
|
| 16 |
+
net.show('tour.html')
|
| 17 |
+
return True
|
| 18 |
+
|
| 19 |
def getTour(income,size,years,sex,edu,wrk):
|
| 20 |
# person = a dict with person-level and hh-level attributes:
|
| 21 |
person = {}
|
|
|
|
| 80 |
print(e)
|
| 81 |
else:
|
| 82 |
print("Nothing extracted!")
|
| 83 |
+
success = vizTour(activity_list)
|
| 84 |
+
return activity_list, success
|
| 85 |
|
| 86 |
with gr.Interface(fn=getTour, inputs=[
|
| 87 |
gr.inputs.Textbox(label="Annual Household Income (in dollars)"),
|
|
|
|
| 89 |
gr.inputs.Textbox(label="Traveler Age (years)"),
|
| 90 |
gr.inputs.Dropdown(["unknown", "male", "female"], label="Gender/sex"),
|
| 91 |
gr.inputs.Dropdown(["unknown", "grade school","highschool", "associates", "bachelors", "graduate"], label="Educational attainment level"),
|
| 92 |
+
gr.inputs.Dropdown(["unknown", "yes","no"], label="Worker status")],
|
| 93 |
+
outputs=["json",
|
| 94 |
+
gr.HTML(value=open('tour.html'))], title="GPT-Tour", description="Generate a tour for a person", allow_flagging=False, allow_screenshot=False, allow_embedding=False) as iface:
|
| 95 |
iface.launch()
|
requirements.txt
CHANGED
|
@@ -1,2 +1,3 @@
|
|
| 1 |
torch
|
| 2 |
-
transformers
|
|
|
|
|
|
| 1 |
torch
|
| 2 |
+
transformers
|
| 3 |
+
pyviz
|