Spaces:
Running
Running
File size: 1,566 Bytes
1774ce2 75a1da3 1774ce2 75a1da3 1774ce2 75a1da3 1774ce2 75a1da3 1774ce2 75a1da3 1774ce2 75a1da3 1774ce2 75a1da3 |
1 2 3 4 5 6 7 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 |
import shlex
import subprocess
import os
import sys
from huggingface_hub import snapshot_download
import torch
import fire
import gradio as gr
from gradio_app.gradio_3dgen import create_ui as create_3d_ui
from gradio_app.all_models import model_zoo
# Install required packages
def setup_dependencies():
subprocess.run(shlex.split("pip install pip==24.0"), check=True)
subprocess.run(
shlex.split(
"pip install package/onnxruntime_gpu-1.17.0-cp310-cp310-manylinux_2_28_x86_64.whl --force-reinstall --no-deps"
),
check=True
)
subprocess.run(
shlex.split(
"pip install package/nvdiffrast-0.3.1.torch-cp310-cp310-linux_x86_64.whl --force-reinstall --no-deps"
),
check=True
)
# Download model checkpoints
def setup_model():
snapshot_download("public-data/Unique3D", repo_type="model", local_dir="./ckpt")
# Configure PyTorch settings
torch.set_float32_matmul_precision('medium')
torch.backends.cuda.matmul.allow_tf32 = True
torch.set_grad_enabled(False)
# Application title
_TITLE = 'Text to 3D'
def launch():
# Initialize models
model_zoo.init_models()
# Create Gradio interface
with gr.Blocks(title=_TITLE) as demo:
with gr.Row():
with gr.Column(scale=1):
gr.Markdown('# ' + _TITLE)
create_3d_ui("wkl")
demo.queue().launch(share=True)
if __name__ == '__main__':
setup_dependencies()
setup_model()
sys.path.append(os.curdir)
fire.Fire(launch) |