Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -239,14 +239,7 @@ pipeline = XoraVideoPipeline(
|
|
| 239 |
vae=vae,
|
| 240 |
).to(device)
|
| 241 |
|
| 242 |
-
# State λ³μλ€μ μ΄κΈ°ν μμ
|
| 243 |
-
txt2vid_current_height = gr.State(value=320)
|
| 244 |
-
txt2vid_current_width = gr.State(value=512)
|
| 245 |
-
txt2vid_current_num_frames = gr.State(value=257)
|
| 246 |
|
| 247 |
-
img2vid_current_height = gr.State(value=320)
|
| 248 |
-
img2vid_current_width = gr.State(value=512)
|
| 249 |
-
img2vid_current_num_frames = gr.State(value=257)
|
| 250 |
|
| 251 |
# Preset options for resolution and frame configuration
|
| 252 |
# Convert frames to seconds assuming 25 FPS
|
|
@@ -279,16 +272,18 @@ preset_options = [
|
|
| 279 |
]
|
| 280 |
|
| 281 |
def preset_changed(preset):
|
| 282 |
-
selected = next(item for item in preset_options if item["label"] == preset)
|
|
|
|
|
|
|
| 283 |
return [
|
| 284 |
-
selected["height"],
|
| 285 |
-
selected["width"],
|
| 286 |
-
selected["num_frames"],
|
| 287 |
gr.update(visible=False),
|
| 288 |
gr.update(visible=False),
|
| 289 |
gr.update(visible=False),
|
| 290 |
-
]
|
| 291 |
-
|
| 292 |
def generate_video_from_text(
|
| 293 |
prompt,
|
| 294 |
enhance_prompt_toggle,
|
|
@@ -849,6 +844,16 @@ def cleanup():
|
|
| 849 |
|
| 850 |
# Gradio Interface Definition
|
| 851 |
with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange") as iface:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 852 |
with gr.Tabs():
|
| 853 |
# Text to Video Tab
|
| 854 |
with gr.TabItem("ν
μ€νΈλ‘ λΉλμ€ λ§λ€κΈ°"):
|
|
@@ -1052,192 +1057,171 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange") as iface:
|
|
| 1052 |
merged_video_output = gr.Video(label="ν΅ν© μμ")
|
| 1053 |
|
| 1054 |
|
| 1055 |
-
|
| 1056 |
-
|
| 1057 |
-
|
| 1058 |
-
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
| 1062 |
-
|
| 1063 |
-
|
| 1064 |
-
|
| 1065 |
-
|
| 1066 |
-
|
| 1067 |
-
|
| 1068 |
-
|
| 1069 |
-
|
| 1070 |
-
|
| 1071 |
-
|
| 1072 |
-
|
| 1073 |
-
|
| 1074 |
-
|
| 1075 |
-
|
| 1076 |
-
|
| 1077 |
-
|
| 1078 |
-
|
| 1079 |
-
|
| 1080 |
-
|
| 1081 |
-
|
| 1082 |
-
|
| 1083 |
-
|
| 1084 |
-
|
| 1085 |
-
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
-
|
| 1090 |
-
|
| 1091 |
-
|
| 1092 |
-
|
| 1093 |
-
|
| 1094 |
-
|
| 1095 |
-
|
| 1096 |
-
|
| 1097 |
-
|
| 1098 |
-
|
| 1099 |
-
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
-
|
| 1107 |
-
|
| 1108 |
-
|
| 1109 |
-
|
| 1110 |
-
|
| 1111 |
-
|
| 1112 |
-
|
| 1113 |
-
|
| 1114 |
-
|
| 1115 |
-
|
| 1116 |
-
|
| 1117 |
-
|
| 1118 |
-
|
| 1119 |
-
|
| 1120 |
-
|
| 1121 |
-
|
| 1122 |
-
|
| 1123 |
-
|
| 1124 |
-
|
| 1125 |
-
|
| 1126 |
-
|
| 1127 |
-
|
| 1128 |
-
|
| 1129 |
-
|
| 1130 |
-
|
| 1131 |
-
|
| 1132 |
-
|
| 1133 |
-
|
| 1134 |
-
|
| 1135 |
-
|
| 1136 |
-
|
| 1137 |
-
|
| 1138 |
-
|
| 1139 |
-
|
| 1140 |
-
|
| 1141 |
-
|
| 1142 |
-
|
| 1143 |
-
|
| 1144 |
-
|
| 1145 |
-
|
| 1146 |
-
|
| 1147 |
-
|
| 1148 |
-
|
| 1149 |
-
|
| 1150 |
-
|
| 1151 |
-
|
| 1152 |
-
|
| 1153 |
-
|
| 1154 |
-
|
| 1155 |
-
|
| 1156 |
-
|
| 1157 |
-
|
| 1158 |
-
|
| 1159 |
-
|
| 1160 |
-
|
| 1161 |
-
|
| 1162 |
-
|
| 1163 |
-
|
| 1164 |
-
|
| 1165 |
-
|
| 1166 |
-
|
| 1167 |
-
|
| 1168 |
-
|
| 1169 |
-
|
| 1170 |
-
|
| 1171 |
-
|
| 1172 |
-
|
| 1173 |
-
|
| 1174 |
-
|
| 1175 |
-
|
| 1176 |
-
|
| 1177 |
-
|
| 1178 |
-
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
| 1186 |
-
|
| 1187 |
-
|
| 1188 |
-
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
-
|
| 1193 |
-
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
|
| 1200 |
-
|
| 1201 |
-
|
| 1202 |
-
|
| 1203 |
-
|
| 1204 |
-
|
| 1205 |
-
|
| 1206 |
-
|
| 1207 |
-
|
| 1208 |
-
|
| 1209 |
-
|
| 1210 |
-
|
| 1211 |
-
|
| 1212 |
-
|
| 1213 |
-
|
| 1214 |
-
|
| 1215 |
-
|
| 1216 |
-
|
| 1217 |
-
|
| 1218 |
-
|
| 1219 |
-
|
| 1220 |
-
outputs=section4_video
|
| 1221 |
-
)
|
| 1222 |
-
|
| 1223 |
-
section5_generate.click(
|
| 1224 |
-
fn=lambda p, pr: generate_section_video(p, pr, 5),
|
| 1225 |
-
inputs=[section5_prompt, scenario_preset],
|
| 1226 |
-
outputs=section5_video
|
| 1227 |
-
)
|
| 1228 |
-
|
| 1229 |
-
# ν΅ν© μμ μμ± νΈλ€λ¬
|
| 1230 |
-
merge_videos_btn.click(
|
| 1231 |
-
fn=merge_section_videos,
|
| 1232 |
-
inputs=[
|
| 1233 |
-
section1_video,
|
| 1234 |
-
section2_video,
|
| 1235 |
-
section3_video,
|
| 1236 |
-
section4_video,
|
| 1237 |
-
section5_video
|
| 1238 |
-
],
|
| 1239 |
-
outputs=merged_video_output
|
| 1240 |
-
)
|
| 1241 |
|
| 1242 |
if __name__ == "__main__":
|
| 1243 |
iface.queue(max_size=64, default_concurrency_limit=1, api_open=False).launch(
|
|
|
|
| 239 |
vae=vae,
|
| 240 |
).to(device)
|
| 241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
|
|
|
|
|
|
|
|
|
| 243 |
|
| 244 |
# Preset options for resolution and frame configuration
|
| 245 |
# Convert frames to seconds assuming 25 FPS
|
|
|
|
| 272 |
]
|
| 273 |
|
| 274 |
def preset_changed(preset):
|
| 275 |
+
selected = next((item for item in preset_options if item["label"] == preset), None)
|
| 276 |
+
if selected is None:
|
| 277 |
+
raise gr.Error("Invalid preset selected")
|
| 278 |
return [
|
| 279 |
+
gr.State(value=selected["height"]),
|
| 280 |
+
gr.State(value=selected["width"]),
|
| 281 |
+
gr.State(value=selected["num_frames"]),
|
| 282 |
gr.update(visible=False),
|
| 283 |
gr.update(visible=False),
|
| 284 |
gr.update(visible=False),
|
| 285 |
+
]
|
| 286 |
+
|
| 287 |
def generate_video_from_text(
|
| 288 |
prompt,
|
| 289 |
enhance_prompt_toggle,
|
|
|
|
| 844 |
|
| 845 |
# Gradio Interface Definition
|
| 846 |
with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange") as iface:
|
| 847 |
+
|
| 848 |
+
# State λ³μλ€μ μ΄κΈ°ν μμ
|
| 849 |
+
txt2vid_current_height = gr.State(value=320)
|
| 850 |
+
txt2vid_current_width = gr.State(value=512)
|
| 851 |
+
txt2vid_current_num_frames = gr.State(value=257)
|
| 852 |
+
|
| 853 |
+
img2vid_current_height = gr.State(value=320)
|
| 854 |
+
img2vid_current_width = gr.State(value=512)
|
| 855 |
+
img2vid_current_num_frames = gr.State(value=257)
|
| 856 |
+
|
| 857 |
with gr.Tabs():
|
| 858 |
# Text to Video Tab
|
| 859 |
with gr.TabItem("ν
μ€νΈλ‘ λΉλμ€ λ§λ€κΈ°"):
|
|
|
|
| 1057 |
merged_video_output = gr.Video(label="ν΅ν© μμ")
|
| 1058 |
|
| 1059 |
|
| 1060 |
+
# Text to Video Tab handlers
|
| 1061 |
+
txt2vid_preset.change(
|
| 1062 |
+
fn=preset_changed,
|
| 1063 |
+
inputs=[txt2vid_preset],
|
| 1064 |
+
outputs=[
|
| 1065 |
+
txt2vid_current_height,
|
| 1066 |
+
txt2vid_current_width,
|
| 1067 |
+
txt2vid_current_num_frames,
|
| 1068 |
+
txt2vid_advanced[3], # height_slider
|
| 1069 |
+
txt2vid_advanced[4], # width_slider
|
| 1070 |
+
txt2vid_advanced[5], # num_frames_slider
|
| 1071 |
+
]
|
| 1072 |
+
)
|
| 1073 |
+
|
| 1074 |
+
txt2vid_enhance_toggle.change(
|
| 1075 |
+
fn=update_prompt_t2v,
|
| 1076 |
+
inputs=[txt2vid_prompt, txt2vid_enhance_toggle],
|
| 1077 |
+
outputs=txt2vid_prompt
|
| 1078 |
+
)
|
| 1079 |
+
|
| 1080 |
+
txt2vid_generate.click(
|
| 1081 |
+
fn=generate_video_from_text,
|
| 1082 |
+
inputs=[
|
| 1083 |
+
txt2vid_prompt,
|
| 1084 |
+
txt2vid_enhance_toggle,
|
| 1085 |
+
txt2vid_negative_prompt,
|
| 1086 |
+
txt2vid_frame_rate,
|
| 1087 |
+
txt2vid_advanced[0], # seed
|
| 1088 |
+
txt2vid_advanced[1], # inference_steps
|
| 1089 |
+
txt2vid_advanced[2], # guidance_scale
|
| 1090 |
+
txt2vid_current_height,
|
| 1091 |
+
txt2vid_current_width,
|
| 1092 |
+
txt2vid_current_num_frames,
|
| 1093 |
+
],
|
| 1094 |
+
outputs=txt2vid_output,
|
| 1095 |
+
)
|
| 1096 |
+
|
| 1097 |
+
# Image to Video Tab handlers
|
| 1098 |
+
img2vid_preset.change(
|
| 1099 |
+
fn=preset_changed,
|
| 1100 |
+
inputs=[img2vid_preset],
|
| 1101 |
+
outputs=[
|
| 1102 |
+
img2vid_current_height,
|
| 1103 |
+
img2vid_current_width,
|
| 1104 |
+
img2vid_current_num_frames,
|
| 1105 |
+
img2vid_advanced[3], # height_slider
|
| 1106 |
+
img2vid_advanced[4], # width_slider
|
| 1107 |
+
img2vid_advanced[5], # num_frames_slider
|
| 1108 |
+
]
|
| 1109 |
+
)
|
| 1110 |
+
|
| 1111 |
+
img2vid_enhance_toggle.change(
|
| 1112 |
+
fn=update_prompt_i2v,
|
| 1113 |
+
inputs=[img2vid_prompt, img2vid_enhance_toggle],
|
| 1114 |
+
outputs=img2vid_prompt
|
| 1115 |
+
)
|
| 1116 |
+
|
| 1117 |
+
img2vid_generate.click(
|
| 1118 |
+
fn=generate_video_from_image,
|
| 1119 |
+
inputs=[
|
| 1120 |
+
img2vid_image,
|
| 1121 |
+
img2vid_prompt,
|
| 1122 |
+
img2vid_enhance_toggle,
|
| 1123 |
+
img2vid_negative_prompt,
|
| 1124 |
+
img2vid_frame_rate,
|
| 1125 |
+
img2vid_advanced[0], # seed
|
| 1126 |
+
img2vid_advanced[1], # inference_steps
|
| 1127 |
+
img2vid_advanced[2], # guidance_scale
|
| 1128 |
+
img2vid_current_height,
|
| 1129 |
+
img2vid_current_width,
|
| 1130 |
+
img2vid_current_num_frames,
|
| 1131 |
+
],
|
| 1132 |
+
outputs=img2vid_output,
|
| 1133 |
+
)
|
| 1134 |
+
|
| 1135 |
+
# Scenario Tab handlers
|
| 1136 |
+
generate_script_btn.click(
|
| 1137 |
+
fn=generate_script,
|
| 1138 |
+
inputs=[script_topic],
|
| 1139 |
+
outputs=[scenario_input]
|
| 1140 |
+
)
|
| 1141 |
+
|
| 1142 |
+
analyze_btn.click(
|
| 1143 |
+
fn=analyze_scenario,
|
| 1144 |
+
inputs=[scenario_input],
|
| 1145 |
+
outputs=[
|
| 1146 |
+
section1_prompt, section2_prompt, section3_prompt,
|
| 1147 |
+
section4_prompt, section5_prompt
|
| 1148 |
+
]
|
| 1149 |
+
)
|
| 1150 |
+
|
| 1151 |
+
# μΉμ
λ³ ν둬ννΈ μ¬μμ± νΈλ€λ¬
|
| 1152 |
+
section1_regenerate.click(
|
| 1153 |
+
fn=lambda x: generate_single_section_prompt(x, 1),
|
| 1154 |
+
inputs=[scenario_input],
|
| 1155 |
+
outputs=section1_prompt
|
| 1156 |
+
)
|
| 1157 |
+
|
| 1158 |
+
section2_regenerate.click(
|
| 1159 |
+
fn=lambda x: generate_single_section_prompt(x, 2),
|
| 1160 |
+
inputs=[scenario_input],
|
| 1161 |
+
outputs=section2_prompt
|
| 1162 |
+
)
|
| 1163 |
+
|
| 1164 |
+
section3_regenerate.click(
|
| 1165 |
+
fn=lambda x: generate_single_section_prompt(x, 3),
|
| 1166 |
+
inputs=[scenario_input],
|
| 1167 |
+
outputs=section3_prompt
|
| 1168 |
+
)
|
| 1169 |
+
|
| 1170 |
+
section4_regenerate.click(
|
| 1171 |
+
fn=lambda x: generate_single_section_prompt(x, 4),
|
| 1172 |
+
inputs=[scenario_input],
|
| 1173 |
+
outputs=section4_prompt
|
| 1174 |
+
)
|
| 1175 |
+
|
| 1176 |
+
section5_regenerate.click(
|
| 1177 |
+
fn=lambda x: generate_single_section_prompt(x, 5),
|
| 1178 |
+
inputs=[scenario_input],
|
| 1179 |
+
outputs=section5_prompt
|
| 1180 |
+
)
|
| 1181 |
+
|
| 1182 |
+
# μΉμ
λ³ λΉλμ€ μμ± νΈλ€λ¬
|
| 1183 |
+
section1_generate.click(
|
| 1184 |
+
fn=lambda p, pr: generate_section_video(p, pr, 1),
|
| 1185 |
+
inputs=[section1_prompt, scenario_preset],
|
| 1186 |
+
outputs=section1_video
|
| 1187 |
+
)
|
| 1188 |
+
|
| 1189 |
+
section2_generate.click(
|
| 1190 |
+
fn=lambda p, pr: generate_section_video(p, pr, 2),
|
| 1191 |
+
inputs=[section2_prompt, scenario_preset],
|
| 1192 |
+
outputs=section2_video
|
| 1193 |
+
)
|
| 1194 |
+
|
| 1195 |
+
section3_generate.click(
|
| 1196 |
+
fn=lambda p, pr: generate_section_video(p, pr, 3),
|
| 1197 |
+
inputs=[section3_prompt, scenario_preset],
|
| 1198 |
+
outputs=section3_video
|
| 1199 |
+
)
|
| 1200 |
+
|
| 1201 |
+
section4_generate.click(
|
| 1202 |
+
fn=lambda p, pr: generate_section_video(p, pr, 4),
|
| 1203 |
+
inputs=[section4_prompt, scenario_preset],
|
| 1204 |
+
outputs=section4_video
|
| 1205 |
+
)
|
| 1206 |
+
|
| 1207 |
+
section5_generate.click(
|
| 1208 |
+
fn=lambda p, pr: generate_section_video(p, pr, 5),
|
| 1209 |
+
inputs=[section5_prompt, scenario_preset],
|
| 1210 |
+
outputs=section5_video
|
| 1211 |
+
)
|
| 1212 |
+
|
| 1213 |
+
# ν΅ν© μμ μμ± νΈλ€λ¬
|
| 1214 |
+
merge_videos_btn.click(
|
| 1215 |
+
fn=merge_section_videos,
|
| 1216 |
+
inputs=[
|
| 1217 |
+
section1_video,
|
| 1218 |
+
section2_video,
|
| 1219 |
+
section3_video,
|
| 1220 |
+
section4_video,
|
| 1221 |
+
section5_video
|
| 1222 |
+
],
|
| 1223 |
+
outputs=merged_video_output
|
| 1224 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1225 |
|
| 1226 |
if __name__ == "__main__":
|
| 1227 |
iface.queue(max_size=64, default_concurrency_limit=1, api_open=False).launch(
|