jonathanagustin
commited on
Commit
•
eaaac1a
1
Parent(s):
13d6ce1
Update app.py
Browse files
app.py
CHANGED
@@ -194,11 +194,10 @@ class LiveYouTubeObjectDetector:
|
|
194 |
@staticmethod
|
195 |
def get_live_streams(query=""):
|
196 |
return SearchService.search(query if query else "world live cams", SearchFilter.LIVE)
|
197 |
-
|
198 |
def render(self):
|
199 |
with gr.Blocks(title="Object Detection in Live YouTube Streams",
|
200 |
-
css="footer {visibility: hidden}",
|
201 |
-
analytics_enabled=False) as app:
|
202 |
self.page_title.render()
|
203 |
with gr.Column():
|
204 |
with gr.Group():
|
@@ -212,28 +211,28 @@ class LiveYouTubeObjectDetector:
|
|
212 |
self.search_button.render()
|
213 |
with gr.Row():
|
214 |
self.gallery.render()
|
215 |
-
|
216 |
@self.gallery.select(inputs=None, outputs=[self.annotated_image, self.stream_input], scroll_to_output=True)
|
217 |
def detect_objects_from_gallery_item(evt: gr.SelectData):
|
218 |
if evt.index is not None and evt.index < len(self.streams):
|
219 |
selected_stream = self.streams[evt.index]
|
220 |
stream_url = SearchService.get_youtube_url(selected_stream["video_id"])
|
221 |
self.stream_input.value = stream_url
|
222 |
-
|
223 |
-
|
224 |
-
|
|
|
225 |
@self.search_button.click(inputs=[self.search_input], outputs=[self.gallery])
|
226 |
def search_live_streams(query):
|
227 |
self.streams = self.get_live_streams(query)
|
228 |
gallery_items = [(stream["thumbnail_url"], stream["title"]) for stream in self.streams]
|
229 |
return gallery_items
|
230 |
-
|
231 |
@self.submit_button.click(inputs=[self.stream_input], outputs=[self.annotated_image])
|
232 |
def detect_objects_from_url(url):
|
233 |
return self.detect_objects(url)
|
234 |
-
|
235 |
app.queue().launch(show_api=False, debug=True)
|
236 |
|
237 |
-
|
238 |
if __name__ == "__main__":
|
239 |
LiveYouTubeObjectDetector().render()
|
|
|
194 |
@staticmethod
|
195 |
def get_live_streams(query=""):
|
196 |
return SearchService.search(query if query else "world live cams", SearchFilter.LIVE)
|
197 |
+
|
198 |
def render(self):
|
199 |
with gr.Blocks(title="Object Detection in Live YouTube Streams",
|
200 |
+
css="footer {visibility: hidden}", analytics_enabled=False) as app:
|
|
|
201 |
self.page_title.render()
|
202 |
with gr.Column():
|
203 |
with gr.Group():
|
|
|
211 |
self.search_button.render()
|
212 |
with gr.Row():
|
213 |
self.gallery.render()
|
214 |
+
|
215 |
@self.gallery.select(inputs=None, outputs=[self.annotated_image, self.stream_input], scroll_to_output=True)
|
216 |
def detect_objects_from_gallery_item(evt: gr.SelectData):
|
217 |
if evt.index is not None and evt.index < len(self.streams):
|
218 |
selected_stream = self.streams[evt.index]
|
219 |
stream_url = SearchService.get_youtube_url(selected_stream["video_id"])
|
220 |
self.stream_input.value = stream_url
|
221 |
+
annotated_image_result = self.detect_objects(stream_url)
|
222 |
+
return annotated_image_result, stream_url
|
223 |
+
return self.create_black_image(), ""
|
224 |
+
|
225 |
@self.search_button.click(inputs=[self.search_input], outputs=[self.gallery])
|
226 |
def search_live_streams(query):
|
227 |
self.streams = self.get_live_streams(query)
|
228 |
gallery_items = [(stream["thumbnail_url"], stream["title"]) for stream in self.streams]
|
229 |
return gallery_items
|
230 |
+
|
231 |
@self.submit_button.click(inputs=[self.stream_input], outputs=[self.annotated_image])
|
232 |
def detect_objects_from_url(url):
|
233 |
return self.detect_objects(url)
|
234 |
+
|
235 |
app.queue().launch(show_api=False, debug=True)
|
236 |
|
|
|
237 |
if __name__ == "__main__":
|
238 |
LiveYouTubeObjectDetector().render()
|