Update app.py
Browse files
app.py
CHANGED
|
@@ -1,117 +1,71 @@
|
|
| 1 |
-
|
| 2 |
-
from
|
| 3 |
import subprocess
|
| 4 |
-
import tempfile
|
| 5 |
-
import shutil
|
| 6 |
-
import os
|
| 7 |
-
import spaces
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
"
|
| 58 |
-
"
|
| 59 |
-
"
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
temp_config_path = temp_file.name
|
| 77 |
-
|
| 78 |
-
cmd = [
|
| 79 |
-
"torchrun", "--standalone", "--nproc_per_node", "1",
|
| 80 |
-
"scripts/inference.py", temp_config_path,
|
| 81 |
-
"--ckpt-path", ckpt_path
|
| 82 |
-
]
|
| 83 |
-
subprocess.run(cmd)
|
| 84 |
-
|
| 85 |
-
save_dir = "./outputs/samples/" # Örneğin, inference.py tarafından kullanılan kayıt dizini
|
| 86 |
-
list_of_files = glob.glob(f'{save_dir}/*')
|
| 87 |
-
if list_of_files:
|
| 88 |
-
latest_file = max(list_of_files, key=os.path.getctime)
|
| 89 |
-
return latest_file
|
| 90 |
-
else:
|
| 91 |
-
print("No files found in the output directory.")
|
| 92 |
-
return None
|
| 93 |
-
|
| 94 |
-
# Clean up the temporary files
|
| 95 |
-
os.remove(temp_file.name)
|
| 96 |
-
os.remove(prompt_file.name)
|
| 97 |
-
|
| 98 |
-
def main():
|
| 99 |
-
gr.Interface(
|
| 100 |
-
fn=run_inference,
|
| 101 |
-
inputs=[
|
| 102 |
-
gr.Dropdown(choices=[
|
| 103 |
-
"OpenSora-v1-16x256x256.pth",
|
| 104 |
-
"OpenSora-v1-HQ-16x256x256.pth",
|
| 105 |
-
"OpenSora-v1-HQ-16x512x512.pth"
|
| 106 |
-
],
|
| 107 |
-
value="OpenSora-v1-16x256x256.pth",
|
| 108 |
-
label="Model Selection"),
|
| 109 |
-
gr.Textbox(label="Prompt Text", value="Enter prompt text here")
|
| 110 |
-
],
|
| 111 |
-
outputs=gr.Video(label="Output Video"),
|
| 112 |
-
title="Open-Sora Inference",
|
| 113 |
-
description="Run Open-Sora Inference with Custom Parameters",
|
| 114 |
-
).launch()
|
| 115 |
-
|
| 116 |
-
if __name__ == "__main__":
|
| 117 |
-
main()
|
|
|
|
| 1 |
+
from typing import List
|
| 2 |
+
from setuptools import find_packages, setup
|
| 3 |
import subprocess
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
def fetch_requirements(path) -> List[str]:
|
| 6 |
+
"""
|
| 7 |
+
This function reads the requirements file.
|
| 8 |
+
|
| 9 |
+
Args:
|
| 10 |
+
path (str): the path to the requirements file.
|
| 11 |
+
|
| 12 |
+
Returns:
|
| 13 |
+
The lines in the requirements file.
|
| 14 |
+
"""
|
| 15 |
+
with open(path, "r") as fd:
|
| 16 |
+
return [r.strip() for r in fd.readlines()]
|
| 17 |
+
|
| 18 |
+
def fetch_readme() -> str:
|
| 19 |
+
"""
|
| 20 |
+
This function reads the README.md file in the current directory.
|
| 21 |
+
|
| 22 |
+
Returns:
|
| 23 |
+
The lines in the README file.
|
| 24 |
+
"""
|
| 25 |
+
with open("README.md", encoding="utf-8") as f:
|
| 26 |
+
return f.read()
|
| 27 |
+
|
| 28 |
+
setup(
|
| 29 |
+
name="opensora",
|
| 30 |
+
version="1.0.0",
|
| 31 |
+
packages=find_packages(
|
| 32 |
+
exclude=(
|
| 33 |
+
"assets",
|
| 34 |
+
"configs",
|
| 35 |
+
"docs",
|
| 36 |
+
"outputs",
|
| 37 |
+
"pretrained_models",
|
| 38 |
+
"scripts",
|
| 39 |
+
"tests",
|
| 40 |
+
"tools",
|
| 41 |
+
"*.egg-info",
|
| 42 |
+
)
|
| 43 |
+
),
|
| 44 |
+
description="Democratizing Efficient Video Production for All",
|
| 45 |
+
long_description=fetch_readme(),
|
| 46 |
+
long_description_content_type="text/markdown",
|
| 47 |
+
license="Apache Software License 2.0",
|
| 48 |
+
install_requires=fetch_requirements("requirements.txt"),
|
| 49 |
+
python_requires=">=3.6",
|
| 50 |
+
classifiers=[
|
| 51 |
+
"Programming Language :: Python :: 3",
|
| 52 |
+
"License :: OSI Approved :: Apache Software License",
|
| 53 |
+
"Environment :: GPU :: NVIDIA CUDA",
|
| 54 |
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
| 55 |
+
"Topic :: System :: Distributed Computing",
|
| 56 |
+
],
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
install_options = [
|
| 60 |
+
"--disable-pip-version-check",
|
| 61 |
+
"--no-cache-dir",
|
| 62 |
+
"--no-build-isolation",
|
| 63 |
+
"--config-settings", "--build-option=--cpp_ext",
|
| 64 |
+
"--config-settings", "--build-option=--cuda_ext"
|
| 65 |
+
]
|
| 66 |
+
|
| 67 |
+
subprocess.run(
|
| 68 |
+
["pip", "install", "-v"] + install_options + ["git+https://github.com/kadirnar/apex.git"],
|
| 69 |
+
check=True,
|
| 70 |
+
capture_output=True
|
| 71 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|