Spaces:
Runtime error
Runtime error
frankleeeee
commited on
Commit
•
f58f053
1
Parent(s):
8a77797
udpated
Browse files
app.py
CHANGED
@@ -52,7 +52,7 @@ def install_dependencies(enable_optimization=False):
|
|
52 |
)
|
53 |
|
54 |
if enable_optimization:
|
55 |
-
# install
|
56 |
if not _is_package_available("apex"):
|
57 |
subprocess.run(
|
58 |
f'{sys.executable} -m pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --config-settings "--build-option=--cpp_ext" --config-settings "--build-option=--cuda_ext" git+https://github.com/NVIDIA/apex.git',
|
@@ -142,6 +142,10 @@ def parse_args():
|
|
142 |
# ============================
|
143 |
# Main Gradio Script
|
144 |
# ============================
|
|
|
|
|
|
|
|
|
145 |
# read config
|
146 |
args = parse_args()
|
147 |
config = read_config(CONFIG_MAP[args.model_type])
|
@@ -177,54 +181,59 @@ def run_inference(prompt_text):
|
|
177 |
saved_path = save_sample(samples[0], fps=config.fps, save_path=filename)
|
178 |
return saved_path
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
with gr.
|
183 |
-
with gr.
|
184 |
-
gr.
|
185 |
-
|
186 |
-
|
187 |
-
<
|
188 |
-
<
|
189 |
-
|
190 |
-
|
191 |
-
<
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
198 |
</div>
|
199 |
-
|
200 |
-
|
201 |
-
"""
|
202 |
-
)
|
203 |
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
|
209 |
-
|
210 |
-
|
211 |
|
212 |
-
|
213 |
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
218 |
],
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
227 |
|
228 |
-
|
229 |
-
|
230 |
|
|
|
52 |
)
|
53 |
|
54 |
if enable_optimization:
|
55 |
+
# install apex for fused layernorm
|
56 |
if not _is_package_available("apex"):
|
57 |
subprocess.run(
|
58 |
f'{sys.executable} -m pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --config-settings "--build-option=--cpp_ext" --config-settings "--build-option=--cuda_ext" git+https://github.com/NVIDIA/apex.git',
|
|
|
142 |
# ============================
|
143 |
# Main Gradio Script
|
144 |
# ============================
|
145 |
+
# as `run_inference` needs to be wrapped by `spaces.GPU` and the input can only be the prompt text
|
146 |
+
# so we can't pass the models to `run_inference` as arguments.
|
147 |
+
# instead, we need to define them globally so that we can access these models inside `run_inference`
|
148 |
+
|
149 |
# read config
|
150 |
args = parse_args()
|
151 |
config = read_config(CONFIG_MAP[args.model_type])
|
|
|
181 |
saved_path = save_sample(samples[0], fps=config.fps, save_path=filename)
|
182 |
return saved_path
|
183 |
|
184 |
+
def main():
|
185 |
+
# create demo
|
186 |
+
with gr.Blocks() as demo:
|
187 |
+
with gr.Row():
|
188 |
+
with gr.Column():
|
189 |
+
gr.HTML(
|
190 |
+
"""
|
191 |
+
<div style='text-align: center;'>
|
192 |
+
<p align="center">
|
193 |
+
<img src="https://github.com/hpcaitech/Open-Sora/raw/main/assets/readme/icon.png" width="250"/>
|
194 |
+
</p>
|
195 |
+
<div style="display: flex; gap: 10px; justify-content: center;">
|
196 |
+
<a href="https://github.com/hpcaitech/Open-Sora/stargazers"><img src="https://img.shields.io/github/stars/hpcaitech/Open-Sora?style=social"></a>
|
197 |
+
<a href="https://hpcaitech.github.io/Open-Sora/"><img src="https://img.shields.io/badge/Gallery-View-orange?logo=&"></a>
|
198 |
+
<a href="https://discord.gg/kZakZzrSUT"><img src="https://img.shields.io/badge/Discord-join-blueviolet?logo=discord&"></a>
|
199 |
+
<a href="https://join.slack.com/t/colossalaiworkspace/shared_invite/zt-247ipg9fk-KRRYmUl~u2ll2637WRURVA"><img src="https://img.shields.io/badge/Slack-ColossalAI-blueviolet?logo=slack&"></a>
|
200 |
+
<a href="https://twitter.com/yangyou1991/status/1769411544083996787?s=61&t=jT0Dsx2d-MS5vS9rNM5e5g"><img src="https://img.shields.io/badge/Twitter-Discuss-blue?logo=twitter&"></a>
|
201 |
+
<a href="https://raw.githubusercontent.com/hpcaitech/public_assets/main/colossalai/img/WeChat.png"><img src="https://img.shields.io/badge/微信-小助手加群-green?logo=wechat&"></a>
|
202 |
+
<a href="https://hpc-ai.com/blog/open-sora-v1.0"><img src="https://img.shields.io/badge/Open_Sora-Blog-blue"></a>
|
203 |
+
</div>
|
204 |
+
<h1 style='margin-top: 5px;'>Open-Sora: Democratizing Efficient Video Production for All</h1>
|
205 |
</div>
|
206 |
+
"""
|
207 |
+
)
|
|
|
|
|
208 |
|
209 |
+
with gr.Row():
|
210 |
+
with gr.Column():
|
211 |
+
prompt_text = gr.Textbox(show_label=False, placeholder="Describe your video here", lines=4)
|
212 |
+
submit_button = gr.Button("Generate video")
|
213 |
|
214 |
+
with gr.Column():
|
215 |
+
output_video = gr.Video()
|
216 |
|
217 |
+
submit_button.click(fn=run_inference, inputs=[prompt_text], outputs=output_video)
|
218 |
|
219 |
+
gr.Examples(
|
220 |
+
examples=[
|
221 |
+
[
|
222 |
+
"The video captures the majestic beauty of a waterfall cascading down a cliff into a serene lake. The waterfall, with its powerful flow, is the central focus of the video. The surrounding landscape is lush and green, with trees and foliage adding to the natural beauty of the scene. The camera angle provides a bird's eye view of the waterfall, allowing viewers to appreciate the full height and grandeur of the waterfall. The video is a stunning representation of nature's power and beauty.",
|
223 |
+
],
|
224 |
],
|
225 |
+
fn=run_inference,
|
226 |
+
inputs=[
|
227 |
+
prompt_text,
|
228 |
+
],
|
229 |
+
outputs=[output_video],
|
230 |
+
cache_examples=True,
|
231 |
+
)
|
232 |
+
|
233 |
+
# launch
|
234 |
+
demo.launch(server_port=args.port, server_name=args.host, share=args.share)
|
235 |
+
|
236 |
|
237 |
+
if __name__ == '__main__':
|
238 |
+
main()
|
239 |
|