Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -71,13 +71,15 @@ def save_to_gallery(video_path, prompt):
|
|
71 |
|
72 |
return new_video_path
|
73 |
|
|
|
|
|
74 |
def load_gallery():
|
75 |
if os.path.exists(GALLERY_JSON):
|
76 |
with open(GALLERY_JSON, "r") as f:
|
77 |
gallery = json.load(f)
|
78 |
-
return [
|
79 |
return []
|
80 |
-
|
81 |
def respond(image, prompt, steps, cfg_scale, eta, fs, seed, video_length):
|
82 |
logging.info(f"Received prompt: {prompt}, steps: {steps}, cfg_scale: {cfg_scale}, "
|
83 |
f"eta: {eta}, fs: {fs}, seed: {seed}, video_length: {video_length}")
|
@@ -102,11 +104,9 @@ def respond(image, prompt, steps, cfg_scale, eta, fs, seed, video_length):
|
|
102 |
api_name="/infer"
|
103 |
)
|
104 |
logging.info("API response received: %s", result)
|
105 |
-
|
106 |
-
|
107 |
|
108 |
if isinstance(result, dict) and 'video' in result:
|
109 |
-
saved_video_path
|
110 |
return saved_video_path
|
111 |
else:
|
112 |
raise ValueError("μμμΉ λͺ»ν API μλ΅ νμ")
|
@@ -176,6 +176,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
176 |
inputs=[],
|
177 |
outputs=[input_text, input_image]
|
178 |
)
|
|
|
179 |
with gr.Tab("Gallery"):
|
180 |
gallery = gr.Gallery(
|
181 |
label="Generated Videos",
|
@@ -186,7 +187,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
186 |
object_fit="contain",
|
187 |
height="auto",
|
188 |
preview=True
|
189 |
-
)
|
190 |
selected_video = gr.Video(label="Selected Video")
|
191 |
refresh_btn = gr.Button("Refresh Gallery")
|
192 |
|
@@ -195,13 +196,14 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
195 |
return load_gallery()
|
196 |
|
197 |
def show_video(evt: gr.SelectData):
|
198 |
-
if isinstance(evt.value,
|
199 |
-
return evt.value[
|
200 |
elif isinstance(evt.value, str):
|
201 |
-
return evt.value
|
202 |
else:
|
203 |
-
|
204 |
return None
|
|
|
205 |
|
206 |
refresh_btn.click(fn=update_gallery, inputs=None, outputs=gallery)
|
207 |
demo.load(fn=update_gallery, inputs=None, outputs=gallery)
|
|
|
71 |
|
72 |
return new_video_path
|
73 |
|
74 |
+
|
75 |
+
|
76 |
def load_gallery():
|
77 |
if os.path.exists(GALLERY_JSON):
|
78 |
with open(GALLERY_JSON, "r") as f:
|
79 |
gallery = json.load(f)
|
80 |
+
return [{"image": item["video"], "caption": item["prompt"]} for item in reversed(gallery)]
|
81 |
return []
|
82 |
+
|
83 |
def respond(image, prompt, steps, cfg_scale, eta, fs, seed, video_length):
|
84 |
logging.info(f"Received prompt: {prompt}, steps: {steps}, cfg_scale: {cfg_scale}, "
|
85 |
f"eta: {eta}, fs: {fs}, seed: {seed}, video_length: {video_length}")
|
|
|
104 |
api_name="/infer"
|
105 |
)
|
106 |
logging.info("API response received: %s", result)
|
|
|
|
|
107 |
|
108 |
if isinstance(result, dict) and 'video' in result:
|
109 |
+
saved_video_path = save_to_gallery(result['video'], prompt)
|
110 |
return saved_video_path
|
111 |
else:
|
112 |
raise ValueError("μμμΉ λͺ»ν API μλ΅ νμ")
|
|
|
176 |
inputs=[],
|
177 |
outputs=[input_text, input_image]
|
178 |
)
|
179 |
+
|
180 |
with gr.Tab("Gallery"):
|
181 |
gallery = gr.Gallery(
|
182 |
label="Generated Videos",
|
|
|
187 |
object_fit="contain",
|
188 |
height="auto",
|
189 |
preview=True
|
190 |
+
).style(grid=3)
|
191 |
selected_video = gr.Video(label="Selected Video")
|
192 |
refresh_btn = gr.Button("Refresh Gallery")
|
193 |
|
|
|
196 |
return load_gallery()
|
197 |
|
198 |
def show_video(evt: gr.SelectData):
|
199 |
+
if isinstance(evt.value, dict) and 'image' in evt.value:
|
200 |
+
return evt.value['image']['path']
|
201 |
elif isinstance(evt.value, str):
|
202 |
+
return evt.value
|
203 |
else:
|
204 |
+
logging.error(f"Unexpected evt.value structure: {evt.value}")
|
205 |
return None
|
206 |
+
|
207 |
|
208 |
refresh_btn.click(fn=update_gallery, inputs=None, outputs=gallery)
|
209 |
demo.load(fn=update_gallery, inputs=None, outputs=gallery)
|