Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -5,7 +5,7 @@ emoji: 🔥
|
|
| 5 |
colorFrom: indigo
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
-
sdk_version:
|
| 9 |
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
hf_oauth: true
|
|
|
|
| 5 |
colorFrom: indigo
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
+
sdk_version: 6.0.0
|
| 9 |
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
hf_oauth: true
|
run.ipynb
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: video_subtitle"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: video_subtitle"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "from gradio.media import get_video, get_file\n", "\n", "def video_demo(video, subtitle=None):\n", " if subtitle is None:\n", " return video\n", " return gr.Video(label=\"Out\", value=video, subtitles=subtitle.name)\n", "\n", "demo = gr.Interface(\n", " fn=video_demo,\n", " inputs=[\n", " gr.Video(label=\"In\", interactive=True),\n", " gr.File(label=\"Subtitle\", file_types=[\".srt\", \".vtt\", \".json\"]),\n", " ],\n", " outputs=gr.Video(label=\"Out\"),\n", " examples=[\n", " [get_video(\"a.mp4\"), get_file(\"s1.srt\")],\n", " [get_video(\"b.mp4\"), get_file(\"s2.vtt\")],\n", " [get_video(\"a.mp4\"), get_file(\"s3.json\")],\n", " ],\n", " api_name=\"predict\",\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
|
@@ -1,29 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
a = os.path.join(os.path.dirname(__file__), "files/a.mp4") # Video
|
| 5 |
-
b = os.path.join(os.path.dirname(__file__), "files/b.mp4") # Video
|
| 6 |
-
s1 = os.path.join(os.path.dirname(__file__), "files/s1.srt") # Subtitle
|
| 7 |
-
s2 = os.path.join(os.path.dirname(__file__), "files/s2.vtt") # Subtitle
|
| 8 |
|
| 9 |
def video_demo(video, subtitle=None):
|
| 10 |
if subtitle is None:
|
| 11 |
return video
|
| 12 |
-
|
| 13 |
-
return [video, subtitle.name]
|
| 14 |
|
| 15 |
demo = gr.Interface(
|
| 16 |
fn=video_demo,
|
| 17 |
inputs=[
|
| 18 |
gr.Video(label="In", interactive=True),
|
| 19 |
-
gr.File(label="Subtitle", file_types=[".srt", ".vtt"]),
|
| 20 |
],
|
| 21 |
outputs=gr.Video(label="Out"),
|
| 22 |
examples=[
|
| 23 |
-
[a, s1],
|
| 24 |
-
[b, s2],
|
| 25 |
-
[a,
|
| 26 |
],
|
|
|
|
| 27 |
)
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from gradio.media import get_video, get_file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
def video_demo(video, subtitle=None):
|
| 5 |
if subtitle is None:
|
| 6 |
return video
|
| 7 |
+
return gr.Video(label="Out", value=video, subtitles=subtitle.name)
|
|
|
|
| 8 |
|
| 9 |
demo = gr.Interface(
|
| 10 |
fn=video_demo,
|
| 11 |
inputs=[
|
| 12 |
gr.Video(label="In", interactive=True),
|
| 13 |
+
gr.File(label="Subtitle", file_types=[".srt", ".vtt", ".json"]),
|
| 14 |
],
|
| 15 |
outputs=gr.Video(label="Out"),
|
| 16 |
examples=[
|
| 17 |
+
[get_video("a.mp4"), get_file("s1.srt")],
|
| 18 |
+
[get_video("b.mp4"), get_file("s2.vtt")],
|
| 19 |
+
[get_video("a.mp4"), get_file("s3.json")],
|
| 20 |
],
|
| 21 |
+
api_name="predict",
|
| 22 |
)
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|