import spaces
import argparse
import os
import json
import torch
import sys
import time
import importlib
import numpy as np
from omegaconf import OmegaConf
from huggingface_hub import hf_hub_download
from collections import OrderedDict
import trimesh
from einops import repeat, rearrange
import pytorch_lightning as pl
from typing import Dict, Optional, Tuple, List
import gradio as gr
from typing import Any
proj_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(os.path.join(proj_dir))
import tempfile
import craftsman
from craftsman.systems.base import BaseSystem
from craftsman.utils.config import ExperimentConfig, load_config
from apps.utils import *
from apps.mv_models import GenMVImage
_TITLE = '''CraftsMan: High-fidelity Mesh Generation with 3D Native Generation and Interactive Geometry Refiner'''
_DESCRIPTION = '''
Select or upload a image, then just click 'Generate'.
By mimicking the artist/craftsman modeling workflow, we propose CraftsMan (aka 匠心) that uses 3D Latent Set Diffusion Model that directly generate coarse meshes,
then a multi-view normal enhanced image generation model is used to refine the mesh.
We provide the coarse 3D diffusion part here.
If you found CraftsMan is helpful, please help to ⭐ the
Github Repo. Thanks!
*please note that the model is fliped due to the gradio viewer, please download the obj file and you will get the correct mesh.
*If you have your own multi-view images, you can directly upload it.
'''
_CITE_ = r"""
---
📝 **Citation**
If you find our work useful for your research or applications, please cite using this bibtex:
```bibtex
@article{craftsman,
author = {Weiyu Li and Jiarui Liu and Rui Chen and Yixun Liang and Xuelin Chen and Ping Tan and Xiaoxiao Long},
title = {CraftsMan: High-fidelity Mesh Generation with 3D Native Generation and Interactive Geometry Refiner},
journal = {arxiv:xxx},
year = {2024},
}
```
🤗 **Acknowledgements**
We use