Update a.py
Browse files
a.py
CHANGED
|
@@ -12,24 +12,23 @@ client = Ark(
|
|
| 12 |
api_key=API_KEY,
|
| 13 |
)
|
| 14 |
|
| 15 |
-
def generate_video(
|
| 16 |
"""Generate video using HF temp URL trick"""
|
| 17 |
|
| 18 |
if not API_KEY:
|
| 19 |
yield "❌ API Key not configured. Please add 'Key' secret.", None
|
| 20 |
return
|
| 21 |
|
| 22 |
-
if
|
| 23 |
yield "⚠️ Please upload an image first", None
|
| 24 |
return
|
| 25 |
|
| 26 |
try:
|
| 27 |
progress(0, desc="Preparing image...")
|
| 28 |
|
| 29 |
-
# THE TRICK:
|
| 30 |
-
# When type="filepath", image.name gives us the local path
|
| 31 |
# HF automatically serves it as /file=path
|
| 32 |
-
image_url = f"/file={
|
| 33 |
print(f"Using image URL: {image_url}")
|
| 34 |
|
| 35 |
yield "✅ Image ready! Creating video request...", None
|
|
@@ -109,10 +108,10 @@ with gr.Blocks(title="BytePlus Video Generator", theme=gr.themes.Soft()) as demo
|
|
| 109 |
|
| 110 |
with gr.Row():
|
| 111 |
with gr.Column():
|
| 112 |
-
# Image upload -
|
| 113 |
image_input = gr.Image(
|
| 114 |
label="Upload Starting Image",
|
| 115 |
-
type="filepath", # This
|
| 116 |
height=300
|
| 117 |
)
|
| 118 |
|
|
|
|
| 12 |
api_key=API_KEY,
|
| 13 |
)
|
| 14 |
|
| 15 |
+
def generate_video(image_path, prompt_text, progress=gr.Progress()):
|
| 16 |
"""Generate video using HF temp URL trick"""
|
| 17 |
|
| 18 |
if not API_KEY:
|
| 19 |
yield "❌ API Key not configured. Please add 'Key' secret.", None
|
| 20 |
return
|
| 21 |
|
| 22 |
+
if image_path is None:
|
| 23 |
yield "⚠️ Please upload an image first", None
|
| 24 |
return
|
| 25 |
|
| 26 |
try:
|
| 27 |
progress(0, desc="Preparing image...")
|
| 28 |
|
| 29 |
+
# THE TRICK: image_path is already the file path string
|
|
|
|
| 30 |
# HF automatically serves it as /file=path
|
| 31 |
+
image_url = f"/file={image_path}"
|
| 32 |
print(f"Using image URL: {image_url}")
|
| 33 |
|
| 34 |
yield "✅ Image ready! Creating video request...", None
|
|
|
|
| 108 |
|
| 109 |
with gr.Row():
|
| 110 |
with gr.Column():
|
| 111 |
+
# Image upload - type="filepath" returns a string path
|
| 112 |
image_input = gr.Image(
|
| 113 |
label="Upload Starting Image",
|
| 114 |
+
type="filepath", # This returns a string path
|
| 115 |
height=300
|
| 116 |
)
|
| 117 |
|