Spaces:
Runtime error
Runtime error
update app
Browse files
app.py
CHANGED
|
@@ -1,13 +1,16 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from videosys import CogVideoConfig, VideoSysEngine
|
| 3 |
-
from videosys.models.cogvideo.pipeline import CogVideoPABConfig
|
| 4 |
import os
|
|
|
|
|
|
|
|
|
|
| 5 |
import torch
|
| 6 |
from openai import OpenAI
|
| 7 |
from time import time
|
| 8 |
import tempfile
|
| 9 |
import uuid
|
| 10 |
import logging
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
logging.basicConfig(level=logging.INFO)
|
| 13 |
logger = logging.getLogger(__name__)
|
|
@@ -88,7 +91,7 @@ def generate(engine, prompt, num_inference_steps=50, guidance_scale=6.0):
|
|
| 88 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as temp_file:
|
| 89 |
temp_file.name
|
| 90 |
unique_filename = f"{uuid.uuid4().hex}.mp4"
|
| 91 |
-
output_path = os.path.join(
|
| 92 |
|
| 93 |
engine.save_video(video, output_path)
|
| 94 |
return output_path
|
|
@@ -122,19 +125,6 @@ body {
|
|
| 122 |
min-width: 0;
|
| 123 |
}
|
| 124 |
|
| 125 |
-
|
| 126 |
-
button {
|
| 127 |
-
background-color: #4CAF50;
|
| 128 |
-
color: white;
|
| 129 |
-
border: none;
|
| 130 |
-
cursor: pointer;
|
| 131 |
-
transition: background-color 0.3s;
|
| 132 |
-
}
|
| 133 |
-
|
| 134 |
-
button:hover {
|
| 135 |
-
background-color: #45a049;
|
| 136 |
-
}
|
| 137 |
-
|
| 138 |
.video-output {
|
| 139 |
width: 100%;
|
| 140 |
max-width: 720px;
|
|
@@ -176,7 +166,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 176 |
|
| 177 |
with gr.Row():
|
| 178 |
with gr.Column():
|
| 179 |
-
prompt = gr.Textbox(label="Prompt (Less than 200 Words)", value="
|
| 180 |
with gr.Row():
|
| 181 |
gr.Markdown(
|
| 182 |
"✨Upon pressing the enhanced prompt button, we will use [GLM-4 Model](https://github.com/THUDM/GLM-4) to polish the prompt and overwrite the original one."
|
|
@@ -250,4 +240,5 @@ with gr.Blocks(css=css) as demo:
|
|
| 250 |
enhance_button.click(enhance_prompt_func, inputs=[prompt], outputs=[prompt])
|
| 251 |
|
| 252 |
if __name__ == "__main__":
|
|
|
|
| 253 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
|
| 3 |
+
os.environ["GRADIO_TEMP_DIR"] = os.path.join(os.getcwd(), ".tmp_outputs")
|
| 4 |
+
|
| 5 |
import torch
|
| 6 |
from openai import OpenAI
|
| 7 |
from time import time
|
| 8 |
import tempfile
|
| 9 |
import uuid
|
| 10 |
import logging
|
| 11 |
+
import gradio as gr
|
| 12 |
+
from videosys import CogVideoConfig, VideoSysEngine
|
| 13 |
+
from videosys.models.cogvideo.pipeline import CogVideoPABConfig
|
| 14 |
|
| 15 |
logging.basicConfig(level=logging.INFO)
|
| 16 |
logger = logging.getLogger(__name__)
|
|
|
|
| 91 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as temp_file:
|
| 92 |
temp_file.name
|
| 93 |
unique_filename = f"{uuid.uuid4().hex}.mp4"
|
| 94 |
+
output_path = os.path.join("./temp_outputs", unique_filename)
|
| 95 |
|
| 96 |
engine.save_video(video, output_path)
|
| 97 |
return output_path
|
|
|
|
| 125 |
min-width: 0;
|
| 126 |
}
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
.video-output {
|
| 129 |
width: 100%;
|
| 130 |
max-width: 720px;
|
|
|
|
| 166 |
|
| 167 |
with gr.Row():
|
| 168 |
with gr.Column():
|
| 169 |
+
prompt = gr.Textbox(label="Prompt (Less than 200 Words)", value="Sunset over the sea.", lines=5)
|
| 170 |
with gr.Row():
|
| 171 |
gr.Markdown(
|
| 172 |
"✨Upon pressing the enhanced prompt button, we will use [GLM-4 Model](https://github.com/THUDM/GLM-4) to polish the prompt and overwrite the original one."
|
|
|
|
| 240 |
enhance_button.click(enhance_prompt_func, inputs=[prompt], outputs=[prompt])
|
| 241 |
|
| 242 |
if __name__ == "__main__":
|
| 243 |
+
demo.queue(max_size=10, default_concurrency_limit=1)
|
| 244 |
demo.launch()
|