add a new example
Browse filesSigned-off-by: Zhang Jun <jzhang533@gmail.com>
- .gitattributes +1 -0
- app.py +8 -6
- skiing.mp4 +3 -0
.gitattributes
CHANGED
|
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
sample_demo.mp4 filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
sample_demo.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -49,10 +49,10 @@ def extract_frames(video_path, interval_sec=1):
|
|
| 49 |
def process_chunk_with_retry(client, chunk_index, frames_b64, max_retries=3):
|
| 50 |
"""Send chunk to LLM."""
|
| 51 |
prompt = (
|
| 52 |
-
"This is a segment from a
|
| 53 |
-
"
|
| 54 |
-
"
|
| 55 |
-
"
|
| 56 |
)
|
| 57 |
content = [{"type": "text", "text": prompt}]
|
| 58 |
for f in frames_b64:
|
|
@@ -74,6 +74,8 @@ def aggregate_and_generate_webpage(client, summaries):
|
|
| 74 |
full_summary = "\n".join([f"Segment {i+1} Summary: {s}" for i, s in sorted(summaries.items()) if s])
|
| 75 |
final_prompt = f"""
|
| 76 |
You are an expert Frontend Engineer. Based on the video segment summaries, write a complete HTML file.
|
|
|
|
|
|
|
| 77 |
|
| 78 |
**Summaries:**
|
| 79 |
{full_summary}
|
|
@@ -182,7 +184,7 @@ with gr.Blocks(title="Ernie 4.5 Video2Code", theme=gr.themes.Soft()) as demo:
|
|
| 182 |
* **🚀 Long Context Window**: Supports up to 128k context length for analyzing long tutorials.
|
| 183 |
""")
|
| 184 |
|
| 185 |
-
gr.Markdown("Upload a
|
| 186 |
|
| 187 |
with gr.Row():
|
| 188 |
with gr.Column(scale=1):
|
|
@@ -190,7 +192,7 @@ with gr.Blocks(title="Ernie 4.5 Video2Code", theme=gr.themes.Soft()) as demo:
|
|
| 190 |
video_input = gr.Video(label="Upload Video", format="mp4")
|
| 191 |
|
| 192 |
gr.Examples(
|
| 193 |
-
examples=[["sample_demo.mp4"]],
|
| 194 |
inputs=[video_input],
|
| 195 |
label="▶️ Or try this example video:",
|
| 196 |
cache_examples=False
|
|
|
|
| 49 |
def process_chunk_with_retry(client, chunk_index, frames_b64, max_retries=3):
|
| 50 |
"""Send chunk to LLM."""
|
| 51 |
prompt = (
|
| 52 |
+
"This is a segment from a video. "
|
| 53 |
+
"If code is visible, please extract the HTML, CSS, and JavaScript. "
|
| 54 |
+
"If it is a general video (e.g., sports, nature), describe the scene, colors, and mood to inspire a website design. "
|
| 55 |
+
"Provide a detailed summary suitable for a frontend engineer to build a website from."
|
| 56 |
)
|
| 57 |
content = [{"type": "text", "text": prompt}]
|
| 58 |
for f in frames_b64:
|
|
|
|
| 74 |
full_summary = "\n".join([f"Segment {i+1} Summary: {s}" for i, s in sorted(summaries.items()) if s])
|
| 75 |
final_prompt = f"""
|
| 76 |
You are an expert Frontend Engineer. Based on the video segment summaries, write a complete HTML file.
|
| 77 |
+
If the video was a coding tutorial, reconstruct the code.
|
| 78 |
+
If the video was a general scene, create a modern, responsive website inspired by the video's content (e.g., a skiing resort page for a skiing video).
|
| 79 |
|
| 80 |
**Summaries:**
|
| 81 |
{full_summary}
|
|
|
|
| 184 |
* **🚀 Long Context Window**: Supports up to 128k context length for analyzing long tutorials.
|
| 185 |
""")
|
| 186 |
|
| 187 |
+
gr.Markdown("Upload a video (e.g., a coding tutorial or a scene like skiing). The AI will watch it and generate a website based on the content.")
|
| 188 |
|
| 189 |
with gr.Row():
|
| 190 |
with gr.Column(scale=1):
|
|
|
|
| 192 |
video_input = gr.Video(label="Upload Video", format="mp4")
|
| 193 |
|
| 194 |
gr.Examples(
|
| 195 |
+
examples=[["sample_demo.mp4"], ["skiing.mp4"]],
|
| 196 |
inputs=[video_input],
|
| 197 |
label="▶️ Or try this example video:",
|
| 198 |
cache_examples=False
|
skiing.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3cca642ed04145e8a2df8cea332431be3a4c432f887686bbe52f66a25dd78a3d
|
| 3 |
+
size 8513765
|