Spaces:
Runtime error
Runtime error
add images & videos
Browse filesSigned-off-by: Samhita Alla <[email protected]>
- app.py +6 -2
- examples.json +22 -0
- log.csv +0 -2
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import plotly
|
|
| 9 |
import plotly.express as px
|
| 10 |
import requests
|
| 11 |
from dotenv import load_dotenv
|
|
|
|
| 12 |
from gantry_callback.gantry_util import GantryImageToTextLogger
|
| 13 |
from gantry_callback.s3_util import make_unique_bucket_name
|
| 14 |
|
|
@@ -19,6 +20,8 @@ GANTRY_APP_NAME = os.getenv("GANTRY_APP_NAME")
|
|
| 19 |
GANTRY_KEY = os.getenv("GANTRY_API_KEY")
|
| 20 |
MAPBOX_TOKEN = os.getenv("MAPBOX_TOKEN")
|
| 21 |
|
|
|
|
|
|
|
| 22 |
|
| 23 |
def get_plotly_graph(
|
| 24 |
latitude: float, longitude: float, location: str
|
|
@@ -125,6 +128,7 @@ with gr.Blocks() as demo:
|
|
| 125 |
with gr.Row():
|
| 126 |
# Flag button
|
| 127 |
img_flag_button = gr.Button("Flag this output")
|
|
|
|
| 128 |
with gr.Tab("Video"):
|
| 129 |
with gr.Row():
|
| 130 |
video_input = gr.Video(type="filepath", label="Video")
|
|
@@ -133,6 +137,7 @@ with gr.Blocks() as demo:
|
|
| 133 |
video_coordinates = gr.Textbox(label="Coordinates")
|
| 134 |
video_plot = gr.Plot()
|
| 135 |
video_text_button = gr.Button("Go locate!")
|
|
|
|
| 136 |
with gr.Tab("YouTube Link"):
|
| 137 |
with gr.Row():
|
| 138 |
url_input = gr.Textbox(label="Link")
|
|
@@ -141,6 +146,7 @@ with gr.Blocks() as demo:
|
|
| 141 |
url_coordinates = gr.Textbox(label="Coordinates")
|
| 142 |
url_plot = gr.Plot()
|
| 143 |
url_text_button = gr.Button("Go locate!")
|
|
|
|
| 144 |
|
| 145 |
# Gantry flagging for image #
|
| 146 |
callback = GantryImageToTextLogger(application=GANTRY_APP_NAME, api_key=GANTRY_KEY)
|
|
@@ -174,8 +180,6 @@ with gr.Blocks() as demo:
|
|
| 174 |
outputs=[url_text_output, url_coordinates, url_plot],
|
| 175 |
)
|
| 176 |
|
| 177 |
-
examples = gr.Examples(".", inputs=[img_input, video_input, url_input])
|
| 178 |
-
|
| 179 |
gr.Markdown(
|
| 180 |
"Check out the [GitHub repository](https://github.com/samhita-alla/geolocator) that this demo is based off of."
|
| 181 |
)
|
|
|
|
| 9 |
import plotly.express as px
|
| 10 |
import requests
|
| 11 |
from dotenv import load_dotenv
|
| 12 |
+
|
| 13 |
from gantry_callback.gantry_util import GantryImageToTextLogger
|
| 14 |
from gantry_callback.s3_util import make_unique_bucket_name
|
| 15 |
|
|
|
|
| 20 |
GANTRY_KEY = os.getenv("GANTRY_API_KEY")
|
| 21 |
MAPBOX_TOKEN = os.getenv("MAPBOX_TOKEN")
|
| 22 |
|
| 23 |
+
examples = json.load(open("examples.json"))
|
| 24 |
+
|
| 25 |
|
| 26 |
def get_plotly_graph(
|
| 27 |
latitude: float, longitude: float, location: str
|
|
|
|
| 128 |
with gr.Row():
|
| 129 |
# Flag button
|
| 130 |
img_flag_button = gr.Button("Flag this output")
|
| 131 |
+
gr.Examples(examples["images"], inputs=[img_input])
|
| 132 |
with gr.Tab("Video"):
|
| 133 |
with gr.Row():
|
| 134 |
video_input = gr.Video(type="filepath", label="Video")
|
|
|
|
| 137 |
video_coordinates = gr.Textbox(label="Coordinates")
|
| 138 |
video_plot = gr.Plot()
|
| 139 |
video_text_button = gr.Button("Go locate!")
|
| 140 |
+
gr.Examples(examples["videos"], inputs=[video_input])
|
| 141 |
with gr.Tab("YouTube Link"):
|
| 142 |
with gr.Row():
|
| 143 |
url_input = gr.Textbox(label="Link")
|
|
|
|
| 146 |
url_coordinates = gr.Textbox(label="Coordinates")
|
| 147 |
url_plot = gr.Plot()
|
| 148 |
url_text_button = gr.Button("Go locate!")
|
| 149 |
+
gr.Examples(examples["video_urls"], inputs=[url_input])
|
| 150 |
|
| 151 |
# Gantry flagging for image #
|
| 152 |
callback = GantryImageToTextLogger(application=GANTRY_APP_NAME, api_key=GANTRY_KEY)
|
|
|
|
| 180 |
outputs=[url_text_output, url_coordinates, url_plot],
|
| 181 |
)
|
| 182 |
|
|
|
|
|
|
|
| 183 |
gr.Markdown(
|
| 184 |
"Check out the [GitHub repository](https://github.com/samhita-alla/geolocator) that this demo is based off of."
|
| 185 |
)
|
examples.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"images": [
|
| 3 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/images/argentina.jpg",
|
| 4 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/images/beijing.jpg",
|
| 5 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/images/greece.jpg",
|
| 6 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/images/russia.jpg",
|
| 7 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/images/arizona.jpg",
|
| 8 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/images/switzerland.jpg",
|
| 9 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/images/dubai.jpg"
|
| 10 |
+
],
|
| 11 |
+
"videos": [
|
| 12 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/newyork.mp4",
|
| 13 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/faultinourstars-amsterdam.mp4",
|
| 14 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/lostintranslation-tokyo.mp4",
|
| 15 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/main/services/gradio/data/test/vicky-spain.mp4",
|
| 16 |
+
"https://raw.githubusercontent.com/samhita-alla/geolocator/63ee0ae2c1d1263f2da88221e800c58ce8c02351/services/gradio/data/test/3idiots-india.mp4"
|
| 17 |
+
],
|
| 18 |
+
"video_urls": [
|
| 19 |
+
"https://www.youtube.com/watch?v=wxeQkJTZrsw",
|
| 20 |
+
"https://www.youtube.com/watch?v=Mvdr-epa1hc"
|
| 21 |
+
]
|
| 22 |
+
}
|
log.csv
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
Image,Video,Link
|
| 2 |
-
"data/test/greece.jpg","https://cdn.discordapp.com/attachments/545481172399030272/1029739008986714132/video.mp4","https://www.youtube.com/watch?v=wxeQkJTZrsw"
|
|
|
|
|
|
|
|
|