Spaces:
Runtime error
Runtime error
jiaweir
commited on
Commit
Β·
e618667
1
Parent(s):
b23d71d
# This is a combination of 2 commits.
Browse files# This is the 1st commit message:
init
# The commit message #2 will be skipped:
# # This is a combination of 2 commits.
# # This is the 1st commit message:
#
# init
#
# # The commit message #2 will be skipped:
#
# # # This is a combination of 4 commits.
# # # This is the 1st commit message:
# #
# # init
# #
# # # The commit message #2 will be skipped:
# #
# # # init
# #
# # # The commit message #3 will be skipped:
# #
# # # init
# #
# # # The commit message #4 will be skipped:
# #
# # # init
- .gitattributes +2 -1
- app.py +11 -5
- requirements.txt +2 -0
.gitattributes
CHANGED
|
@@ -33,4 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
-
*.png* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.png* filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.whl filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -6,8 +6,12 @@ from gradio_model4dgs import Model4DGS
|
|
| 6 |
import numpy
|
| 7 |
import hashlib
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
from huggingface_hub import hf_hub_download
|
| 13 |
ckpt_path = hf_hub_download(repo_id="ashawkey/LGM", filename="model_fp16_fixrot.safetensors")
|
|
@@ -34,7 +38,7 @@ def check_video_input(image_block: Image.Image):
|
|
| 34 |
if not os.path.exists(os.path.join('tmp_data', f'{img_hash}_rgba_generated.mp4')):
|
| 35 |
raise gr.Error("Please generate a video first")
|
| 36 |
|
| 37 |
-
|
| 38 |
def optimize_stage_1(image_block: Image.Image, preprocess_chk: bool, seed_slider: int):
|
| 39 |
if not os.path.exists('tmp_data'):
|
| 40 |
os.makedirs('tmp_data')
|
|
@@ -55,7 +59,7 @@ def optimize_stage_1(image_block: Image.Image, preprocess_chk: bool, seed_slider
|
|
| 55 |
# return [os.path.join('logs', 'tmp_rgba_model.ply')]
|
| 56 |
return os.path.join('tmp_data', f'{img_hash}_rgba_generated.mp4')
|
| 57 |
|
| 58 |
-
|
| 59 |
def optimize_stage_2(image_block: Image.Image, seed_slider: int):
|
| 60 |
img_hash = hashlib.sha256(image_block.tobytes()).hexdigest()
|
| 61 |
subprocess.run(f'python lgm/infer.py big --resume {ckpt_path} --test_path tmp_data/{img_hash}_rgba.png', shell=True)
|
|
@@ -86,6 +90,8 @@ if __name__ == "__main__":
|
|
| 86 |
example_fns.sort()
|
| 87 |
examples_full = [os.path.join(example_folder, x) for x in example_fns if x.endswith('.png')]
|
| 88 |
|
|
|
|
|
|
|
| 89 |
# Compose demo layout & data flow
|
| 90 |
with gr.Blocks(title=_TITLE, theme=gr.themes.Soft(), js=js_func) as demo:
|
| 91 |
with gr.Row():
|
|
@@ -132,4 +138,4 @@ if __name__ == "__main__":
|
|
| 132 |
|
| 133 |
# demo.queue().launch(share=True)
|
| 134 |
demo.queue(max_size=10) # <-- Sets up a queue with default parameters
|
| 135 |
-
demo.launch(
|
|
|
|
| 6 |
import numpy
|
| 7 |
import hashlib
|
| 8 |
|
| 9 |
+
import spaces
|
| 10 |
+
|
| 11 |
+
@spaces.GPU
|
| 12 |
+
def install():
|
| 13 |
+
subprocess.run(shlex.split("pip install wheel/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl"))
|
| 14 |
+
os.system('pip install xformers==0.0.23 --no-deps --index-url https://download.pytorch.org/whl/cu118')
|
| 15 |
|
| 16 |
from huggingface_hub import hf_hub_download
|
| 17 |
ckpt_path = hf_hub_download(repo_id="ashawkey/LGM", filename="model_fp16_fixrot.safetensors")
|
|
|
|
| 38 |
if not os.path.exists(os.path.join('tmp_data', f'{img_hash}_rgba_generated.mp4')):
|
| 39 |
raise gr.Error("Please generate a video first")
|
| 40 |
|
| 41 |
+
@spaces.GPU
|
| 42 |
def optimize_stage_1(image_block: Image.Image, preprocess_chk: bool, seed_slider: int):
|
| 43 |
if not os.path.exists('tmp_data'):
|
| 44 |
os.makedirs('tmp_data')
|
|
|
|
| 59 |
# return [os.path.join('logs', 'tmp_rgba_model.ply')]
|
| 60 |
return os.path.join('tmp_data', f'{img_hash}_rgba_generated.mp4')
|
| 61 |
|
| 62 |
+
@spaces.GPU
|
| 63 |
def optimize_stage_2(image_block: Image.Image, seed_slider: int):
|
| 64 |
img_hash = hashlib.sha256(image_block.tobytes()).hexdigest()
|
| 65 |
subprocess.run(f'python lgm/infer.py big --resume {ckpt_path} --test_path tmp_data/{img_hash}_rgba.png', shell=True)
|
|
|
|
| 90 |
example_fns.sort()
|
| 91 |
examples_full = [os.path.join(example_folder, x) for x in example_fns if x.endswith('.png')]
|
| 92 |
|
| 93 |
+
install()
|
| 94 |
+
|
| 95 |
# Compose demo layout & data flow
|
| 96 |
with gr.Blocks(title=_TITLE, theme=gr.themes.Soft(), js=js_func) as demo:
|
| 97 |
with gr.Row():
|
|
|
|
| 138 |
|
| 139 |
# demo.queue().launch(share=True)
|
| 140 |
demo.queue(max_size=10) # <-- Sets up a queue with default parameters
|
| 141 |
+
demo.launch()
|
requirements.txt
CHANGED
|
@@ -30,5 +30,7 @@ rembg[gpu,cli]
|
|
| 30 |
# gradio demo
|
| 31 |
gradio
|
| 32 |
gradio-model4dgs
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-e git+https://github.com/ashawkey/kiuikit.git@main#egg=kiui
|
|
|
|
| 30 |
# gradio demo
|
| 31 |
gradio
|
| 32 |
gradio-model4dgs
|
| 33 |
+
tyro
|
| 34 |
+
roma
|
| 35 |
|
| 36 |
-e git+https://github.com/ashawkey/kiuikit.git@main#egg=kiui
|