Spaces:
Paused
Paused
Update app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211225 unmodified lines1281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112124 unmodified lines217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304import spacesimport osimport sysimport gradio as grimport numpy as npimport torchfrom PIL import Imageimport trimeshimport randomimport subprocessimport shutilfrom transformers import AutoModelForImageSegmentationfrom torchvision import transformsfrom huggingface_hub import hf_hub_download, snapshot_download# --------------------# Runtime installs# --------------------subprocess.run("pip install spandrel==0.4.1 --no-deps", shell=True, check=True)# --------------------# Device# --------------------DEVICE = "cuda" if torch.cuda.is_available() else "cpu"DTYPE = torch.float16print("DEVICE:", DEVICE)# --------------------# Constants# --------------------DEFAULT_FACE_NUMBER = 100000MAX_SEED = np.iinfo(np.int32).maxNUM_VIEWS = 6TRIPOSG_REPO_URL = "https://github.com/VAST-AI-Research/TripoSG.git"MV_ADAPTER_REPO_URL = "https://huggingface.co/spaces/VAST-AI/MV-Adapter-Img2Texture"RMBG_PRETRAINED_MODEL = "checkpoints/RMBG-1.4"TRIPOSG_PRETRAINED_MODEL = "checkpoints/TripoSG"BASE_DIR = os.path.dirname(os.path.abspath(__file__))TMP_DIR = os.path.join(BASE_DIR, "tmp")os.makedirs(TMP_DIR, exist_ok=True)# --------------------# Clone repos# --------------------TRIPOSG_CODE_DIR = os.path.join(BASE_DIR, "triposg")if not os.path.exists(TRIPOSG_CODE_DIR):os.system(f"git clone {TRIPOSG_REPO_URL} {TRIPOSG_CODE_DIR}")MV_ADAPTER_CODE_DIR = os.path.join(BASE_DIR, "mv_adapter")if not os.path.exists(MV_ADAPTER_CODE_DIR):os.system(f"git clone {MV_ADAPTER_REPO_URL} {MV_ADAPTER_CODE_DIR} "f"&& cd {MV_ADAPTER_CODE_DIR} "f"&& git checkout 7d37a97e9bc223cdb8fd26a76bd8dd46504c7c3d")# --------------------# Python path (CRITICAL)# --------------------sys.path.append(TRIPOSG_CODE_DIR)sys.path.append(MV_ADAPTER_CODE_DIR)# --------------------# UI header# --------------------HEADER = """# 🔮 Image to 3D with TripoSGState-of-the-art open-source 3D generation.Texture generation powered by[MV-Adapter HF Space](https://huggingface.co/spaces/VAST-AI/MV-Adapter-Img2Texture)"""# --------------------# TripoSG setup# --------------------from image_process import prepare_imagefrom briarmbg import BriaRMBGsnapshot_download("briaai/RMBG-1.4", local_dir=RMBG_PRETRAINED_MODEL)rmbg_net = BriaRMBG.from_pretrained(RMBG_PRETRAINED_MODEL).to(DEVICE)rmbg_net.eval()from triposg.pipelines.pipeline_triposg import TripoSGPipelinesnapshot_download("VAST-AI/TripoSG", local_dir=TRIPOSG_PRETRAINED_MODEL)triposg_pipe = TripoSGPipeline.from_pretrained(TRIPOSG_PRETRAINED_MODEL).to(DEVICE, DTYPE)# --------------------# MV-Adapter imports (CORRECT)# --------------------from mv_adapter.inference_ig2mv_sdxl import (prepare_pipeline,preprocess_image,remove_bg,)from mv_adapter.mvadapter.utils import (get_orthogonal_camera,tensor_to_image,make_image_grid,)from mv_adapter.mvadapter.utils.render import (NVDiffRastContextWrapper,load_mesh,render,)# --------------------# MV-Adapter pipeline# --------------------mv_adapter_pipe = prepare_pipeline(base_model="stabilityai/stable-diffusion-xl-base-1.0",vae_model="madebyollin/sdxl-vae-fp16-fix",5 unmodified linesdevice=DEVICE,dtype=torch.float16,)# --------------------# BiRefNet background remover# --------------------birefnet = AutoModelForImageSegmentation.from_pretrained("ZhengPeng7/BiRefNet",trust_remote_code=True,).to(DEVICE)transform_image = transforms.Compose([transforms.Resize((1024, 1024)),transforms.ToTensor(),transforms.Normalize([0.485, 0.456, 0.406],[0.229, 0.224, 0.225],),])remove_bg_fn = lambda x: remove_bg(x, birefnet, transform_image, DEVICE)# --------------------# Texture models# --------------------if not os.path.exists("checkpoints/RealESRGAN_x2plus.pth"):hf_hub_download("dtarnow/UPscaler",filename="RealESRGAN_x2plus.pth",local_dir="checkpoints",)if not os.path.exists("checkpoints/big-lama.pt"):subprocess.run("wget -P checkpoints/ ""https://github.com/Sanster/models/releases/download/add_big_lama/big-lama.pt",shell=True,check=True,)# --------------------# Helpers# --------------------def get_random_hex():return os.urandom(8).hex()# --------------------# Main pipeline# --------------------@spaces.GPU(duration=180)def run_full(image: str):seed = 0image_seg = prepare_image(image,bg_color=np.array([1.0, 1.0, 1.0]),rmbg_net=rmbg_net,)outputs = triposg_pipe(image=image_seg,generator=torch.Generator(device=DEVICE).manual_seed(seed),num_inference_steps=50,guidance_scale=7.5,).samples[0]mesh = trimesh.Trimesh(outputs[0].astype(np.float32),np.ascontiguousarray(outputs[1]),)save_dir = os.path.join(TMP_DIR, "examples")os.makedirs(save_dir, exist_ok=True)mesh_path = os.path.join(save_dir, f"mesh_{get_random_hex()}.glb")mesh.export(mesh_path)torch.cuda.empty_cache()# Camerascameras = get_orthogonal_camera(elevation_deg=[0, 0, 0, 0, 89.99, -89.99],distance=[1.8] * NUM_VIEWS,4 unmodified linesazimuth_deg=[x - 90 for x in [0, 90, 180, 270, 180, 180]],device=DEVICE,)ctx = NVDiffRastContextWrapper(device=DEVICE, context_type="cuda")mesh_gpu = load_mesh(mesh_path, rescale=True, device=DEVICE)render_out = render(ctx,mesh_gpu,cameras,height=768,width=768,render_attr=False,normal_background=0.0,)control_images = torch.cat([(render_out.pos + 0.5).clamp(0, 1),(render_out.normal / 2 + 0.5).clamp(0, 1),],dim=-1,).permute(0, 3, 1, 2)image_ref = preprocess_image(remove_bg_fn(Image.open(image)),768,768,)images = mv_adapter_pipe("high quality",height=768,width=768,num_inference_steps=15,guidance_scale=3.0,num_images_per_prompt=NUM_VIEWS,control_image=control_images,reference_image=image_ref,negative_prompt="watermark, ugly, blurry",).imagesmv_image_path = os.path.join(save_dir, f"mv_{get_random_hex()}.png")make_image_grid(images, rows=1).save(mv_image_path)from texture import TexturePipeline, ModProcessConfigtexture_pipe = TexturePipeline(upscaler_ckpt_path="checkpoints/RealESRGAN_x2plus.pth",inpaint_ckpt_path="checkpoints/big-lama.pt",device=DEVICE,)textured_path = texture_pipe(mesh_path=mesh_path,save_dir=save_dir,save_name=f"tex_{get_random_hex()}.glb",uv_unwarp=True,uv_size=4096,rgb_path=mv_image_path,rgb_process_config=ModProcessConfig(view_upscale=True,inpaint_mode="view",),camera_azimuth_deg=[x - 90 for x in [0, 90, 180, 270, 180, 180]],)return image_seg, mesh_path, textured_path# --------------------# UI# --------------------with gr.Blocks(title="TripoSG") as demo:gr.Markdown(HEADER)image_input = gr.Image(type="filepath")out_seg = gr.Image()out_mesh = gr.Model3D()out_tex = gr.Model3D()gr.Button("Generate").click(run_full,inputs=image_input,outputs=[out_seg, out_mesh, out_tex],)demo.launch()12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485865 unmodified lines92939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671684 unmodified lines173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468import spacesimport osimport gradio as grimport numpy as npimport torchfrom PIL import Imageimport trimeshimport randomfrom transformers import AutoModelForImageSegmentationfrom torchvision import transformsfrom huggingface_hub import hf_hub_download, snapshot_downloadimport subprocessimport shutil# install otherssubprocess.run("pip install spandrel==0.4.1 --no-deps", shell=True, check=True)DEVICE = "cuda" if torch.cuda.is_available() else "cpu"DTYPE = torch.float16print("DEVICE: ", DEVICE)DEFAULT_FACE_NUMBER = 100000MAX_SEED = np.iinfo(np.int32).maxTRIPOSG_REPO_URL = "https://github.com/VAST-AI-Research/TripoSG.git"MV_ADAPTER_REPO_URL = "https://github.com/huanngzh/MV-Adapter.git"RMBG_PRETRAINED_MODEL = "checkpoints/RMBG-1.4"TRIPOSG_PRETRAINED_MODEL = "checkpoints/TripoSG"TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tmp")os.makedirs(TMP_DIR, exist_ok=True)TRIPOSG_CODE_DIR = "./triposg"if not os.path.exists(TRIPOSG_CODE_DIR):os.system(f"git clone {TRIPOSG_REPO_URL} {TRIPOSG_CODE_DIR}")MV_ADAPTER_CODE_DIR = "./mv_adapter"if not os.path.exists(MV_ADAPTER_CODE_DIR):os.system(f"git clone {MV_ADAPTER_REPO_URL} {MV_ADAPTER_CODE_DIR} && cd {MV_ADAPTER_CODE_DIR} && git checkout 7d37a97e9bc223cdb8fd26a76bd8dd46504c7c3d")import syssys.path.append(TRIPOSG_CODE_DIR)sys.path.append(os.path.join(TRIPOSG_CODE_DIR, "scripts"))sys.path.append(MV_ADAPTER_CODE_DIR)sys.path.append(os.path.join(MV_ADAPTER_CODE_DIR, "scripts"))HEADER = """# 🔮 Image to 3D with [TripoSG](https://github.com/VAST-AI-Research/TripoSG)## State-of-the-art Open Source 3D Generation Using Large-Scale Rectified Flow Transformers<p style="font-size: 1.1em;">By <a href="https://www.tripo3d.ai/" style="color: #1E90FF; text-decoration: none; font-weight: bold;">Tripo</a></p>## 📋 Quick Start Guide:1. **Upload an image** (single object works best)2. Click **Generate Shape** to create the 3D mesh3. Click **Apply Texture** to add textures4. Use **Download GLB** to save your 3D model5. Adjust parameters under **Generation Settings** for fine-tuningBest results come from clean, well-lit images with clear subject isolation. Try it now!<p style="font-size: 0.9em; margin-top: 10px;">Texture generation powered by <a href="https://github.com/huanngzh/MV-Adapter" style="color: #1E90FF; text-decoration: none;">MV-Adapter</a> - a versatile multi-view adapter for consistent texture generation. Try the <a href="https://huggingface.co/spaces/VAST-AI/MV-Adapter-I2MV-SDXL" style="color: #1E90FF; text-decoration: none;">MV-Adapter demo</a> for multi-view image generation.</p>"""# # triposgfrom image_process import prepare_imagefrom briarmbg import BriaRMBGsnapshot_download("briaai/RMBG-1.4", local_dir=RMBG_PRETRAINED_MODEL)rmbg_net = BriaRMBG.from_pretrained(RMBG_PRETRAINED_MODEL).to(DEVICE)rmbg_net.eval()from triposg.pipelines.pipeline_triposg import TripoSGPipelinesnapshot_download("VAST-AI/TripoSG", local_dir=TRIPOSG_PRETRAINED_MODEL)triposg_pipe = TripoSGPipeline.from_pretrained(TRIPOSG_PRETRAINED_MODEL).to(DEVICE, DTYPE)# mv adapterNUM_VIEWS = 6from inference_ig2mv_sdxl import prepare_pipeline, preprocess_image, remove_bgfrom mvadapter.utils import get_orthogonal_camera, tensor_to_image, make_image_gridfrom mvadapter.utils.render import NVDiffRastContextWrapper, load_mesh, rendermv_adapter_pipe = prepare_pipeline(base_model="stabilityai/stable-diffusion-xl-base-1.0",vae_model="madebyollin/sdxl-vae-fp16-fix",5 unmodified linesdevice=DEVICE,dtype=torch.float16,)birefnet = AutoModelForImageSegmentation.from_pretrained("ZhengPeng7/BiRefNet", trust_remote_code=True)birefnet.to(DEVICE)transform_image = transforms.Compose([transforms.Resize((1024, 1024)),transforms.ToTensor(),transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),])remove_bg_fn = lambda x: remove_bg(x, birefnet, transform_image, DEVICE)if not os.path.exists("checkpoints/RealESRGAN_x2plus.pth"):hf_hub_download("dtarnow/UPscaler", filename="RealESRGAN_x2plus.pth", local_dir="checkpoints")if not os.path.exists("checkpoints/big-lama.pt"):subprocess.run("wget -P checkpoints/ https://github.com/Sanster/models/releases/download/add_big_lama/big-lama.pt", shell=True, check=True)def start_session(req: gr.Request):save_dir = os.path.join(TMP_DIR, str(req.session_hash))os.makedirs(save_dir, exist_ok=True)print("start session, mkdir", save_dir)def end_session(req: gr.Request):save_dir = os.path.join(TMP_DIR, str(req.session_hash))shutil.rmtree(save_dir)def get_random_hex():random_bytes = os.urandom(8)random_hex = random_bytes.hex()return random_hexdef get_random_seed(randomize_seed, seed):if randomize_seed:seed = random.randint(0, MAX_SEED)return seed@spaces.GPU(duration=180)def run_full(image: str, req: gr.Request):seed = 0num_inference_steps = 50guidance_scale = 7.5simplify = Truetarget_face_num = DEFAULT_FACE_NUMBERimage_seg = prepare_image(image, bg_color=np.array([1.0, 1.0, 1.0]), rmbg_net=rmbg_net)outputs = triposg_pipe(image=image_seg,generator=torch.Generator(device=triposg_pipe.device).manual_seed(seed),num_inference_steps=num_inference_steps,guidance_scale=guidance_scale).samples[0]print("mesh extraction done")mesh = trimesh.Trimesh(outputs[0].astype(np.float32), np.ascontiguousarray(outputs[1]))if simplify:print("start simplify")from utils import simplify_meshmesh = simplify_mesh(mesh, target_face_num)save_dir = os.path.join(TMP_DIR, "examples")os.makedirs(save_dir, exist_ok=True)mesh_path = os.path.join(save_dir, f"triposg_{get_random_hex()}.glb")mesh.export(mesh_path)print("save to ", mesh_path)torch.cuda.empty_cache()height, width = 768, 768# Prepare camerascameras = get_orthogonal_camera(elevation_deg=[0, 0, 0, 0, 89.99, -89.99],distance=[1.8] * NUM_VIEWS,4 unmodified linesazimuth_deg=[x - 90 for x in [0, 90, 180, 270, 180, 180]],device=DEVICE,)ctx = NVDiffRastContextWrapper(device=DEVICE, context_type="cuda")mesh = load_mesh(mesh_path, rescale=True, device=DEVICE)render_out = render(ctx,mesh,cameras,height=height,width=width,render_attr=False,normal_background=0.0,)control_images = (torch.cat([(render_out.pos + 0.5).clamp(0, 1),(render_out.normal / 2 + 0.5).clamp(0, 1),],dim=-1,).permute(0, 3, 1, 2).to(DEVICE))image = Image.open(image)image = remove_bg_fn(image)image = preprocess_image(image, height, width)pipe_kwargs = {}if seed != -1 and isinstance(seed, int):pipe_kwargs["generator"] = torch.Generator(device=DEVICE).manual_seed(seed)images = mv_adapter_pipe("high quality",height=height,width=width,num_inference_steps=15,guidance_scale=3.0,num_images_per_prompt=NUM_VIEWS,control_image=control_images,control_conditioning_scale=1.0,reference_image=image,reference_conditioning_scale=1.0,negative_prompt="watermark, ugly, deformed, noisy, blurry, low contrast",cross_attention_kwargs={"scale": 1.0},**pipe_kwargs,).imagestorch.cuda.empty_cache()mv_image_path = os.path.join(save_dir, f"mv_adapter_{get_random_hex()}.png")make_image_grid(images, rows=1).save(mv_image_path)from texture import TexturePipeline, ModProcessConfigtexture_pipe = TexturePipeline(upscaler_ckpt_path="checkpoints/RealESRGAN_x2plus.pth",inpaint_ckpt_path="checkpoints/big-lama.pt",device=DEVICE,)textured_glb_path = texture_pipe(mesh_path=mesh_path,save_dir=save_dir,save_name=f"texture_mesh_{get_random_hex()}.glb",uv_unwarp=True,uv_size=4096,rgb_path=mv_image_path,rgb_process_config=ModProcessConfig(view_upscale=True, inpaint_mode="view"),camera_azimuth_deg=[x - 90 for x in [0, 90, 180, 270, 180, 180]],)return image_seg, mesh_path, textured_glb_path@spaces.GPU()@torch.no_grad()def run_segmentation(image: str):image = prepare_image(image, bg_color=np.array([1.0, 1.0, 1.0]), rmbg_net=rmbg_net)return image@spaces.GPU(duration=90)@torch.no_grad()def image_to_3d(image: Image.Image,seed: int,num_inference_steps: int,guidance_scale: float,simplify: bool,target_face_num: int,req: gr.Request):outputs = triposg_pipe(image=image,generator=torch.Generator(device=triposg_pipe.device).manual_seed(seed),num_inference_steps=num_inference_steps,guidance_scale=guidance_scale).samples[0]print("mesh extraction done")mesh = trimesh.Trimesh(outputs[0].astype(np.float32), np.ascontiguousarray(outputs[1]))if simplify:print("start simplify")from utils import simplify_meshmesh = simplify_mesh(mesh, target_face_num)save_dir = os.path.join(TMP_DIR, str(req.session_hash))mesh_path = os.path.join(save_dir, f"triposg_{get_random_hex()}.glb")mesh.export(mesh_path)print("save to ", mesh_path)torch.cuda.empty_cache()return mesh_path@spaces.GPU(duration=120)@torch.no_grad()def run_texture(image: Image, mesh_path: str, seed: int, req: gr.Request):height, width = 768, 768# Prepare camerascameras = get_orthogonal_camera(elevation_deg=[0, 0, 0, 0, 89.99, -89.99],distance=[1.8] * NUM_VIEWS,left=-0.55,right=0.55,bottom=-0.55,top=0.55,azimuth_deg=[x - 90 for x in [0, 90, 180, 270, 180, 180]],device=DEVICE,)ctx = NVDiffRastContextWrapper(device=DEVICE, context_type="cuda")mesh = load_mesh(mesh_path, rescale=True, device=DEVICE)render_out = render(ctx,mesh,cameras,height=height,width=width,render_attr=False,normal_background=0.0,)control_images = (torch.cat([(render_out.pos + 0.5).clamp(0, 1),(render_out.normal / 2 + 0.5).clamp(0, 1),],dim=-1,).permute(0, 3, 1, 2).to(DEVICE))image = Image.open(image)image = remove_bg_fn(image)image = preprocess_image(image, height, width)pipe_kwargs = {}if seed != -1 and isinstance(seed, int):pipe_kwargs["generator"] = torch.Generator(device=DEVICE).manual_seed(seed)images = mv_adapter_pipe("high quality",height=height,width=width,num_inference_steps=15,guidance_scale=3.0,num_images_per_prompt=NUM_VIEWS,control_image=control_images,control_conditioning_scale=1.0,reference_image=image,reference_conditioning_scale=1.0,negative_prompt="watermark, ugly, deformed, noisy, blurry, low contrast",cross_attention_kwargs={"scale": 1.0},**pipe_kwargs,).imagestorch.cuda.empty_cache()save_dir = os.path.join(TMP_DIR, str(req.session_hash))mv_image_path = os.path.join(save_dir, f"mv_adapter_{get_random_hex()}.png")make_image_grid(images, rows=1).save(mv_image_path)from texture import TexturePipeline, ModProcessConfigtexture_pipe = TexturePipeline(upscaler_ckpt_path="checkpoints/RealESRGAN_x2plus.pth",inpaint_ckpt_path="checkpoints/big-lama.pt",device=DEVICE,)textured_glb_path = texture_pipe(mesh_path=mesh_path,save_dir=save_dir,save_name=f"texture_mesh_{get_random_hex()}.glb",uv_unwarp=True,uv_size=4096,rgb_path=mv_image_path,rgb_process_config=ModProcessConfig(view_upscale=True, inpaint_mode="view"),camera_azimuth_deg=[x - 90 for x in [0, 90, 180, 270, 180, 180]],)return textured_glb_pathwith gr.Blocks(title="TripoSG") as demo:gr.Markdown(HEADER)with gr.Row():with gr.Column():with gr.Row():image_prompts = gr.Image(label="Input Image", type="filepath")seg_image = gr.Image(label="Segmentation Result", type="pil", format="png", interactive=False)with gr.Accordion("Generation Settings", open=True):seed = gr.Slider(label="Seed",minimum=0,maximum=MAX_SEED,step=0,value=0)randomize_seed = gr.Checkbox(label="Randomize seed", value=True)num_inference_steps = gr.Slider(label="Number of inference steps",minimum=8,maximum=50,step=1,value=50,)guidance_scale = gr.Slider(label="CFG scale",minimum=0.0,maximum=20.0,step=0.1,value=7.0,)with gr.Row():reduce_face = gr.Checkbox(label="Simplify Mesh", value=True)target_face_num = gr.Slider(maximum=1000000, minimum=10000, value=DEFAULT_FACE_NUMBER, label="Target Face Number")gen_button = gr.Button("Generate Shape", variant="primary")gen_texture_button = gr.Button("Apply Texture", interactive=False)with gr.Column():model_output = gr.Model3D(label="Generated GLB", interactive=False)textured_model_output = gr.Model3D(label="Textured GLB", interactive=False)with gr.Row():examples = gr.Examples(examples=[f"{TRIPOSG_CODE_DIR}/assets/example_data/{image}"for image in os.listdir(f"{TRIPOSG_CODE_DIR}/assets/example_data")],fn=run_full,inputs=[image_prompts],outputs=[seg_image, model_output, textured_model_output],cache_examples=True,)gen_button.click(run_segmentation,inputs=[image_prompts],outputs=[seg_image]).then(get_random_seed,inputs=[randomize_seed, seed],outputs=[seed],).then(image_to_3d,inputs=[seg_image,seed,num_inference_steps,guidance_scale,reduce_face,target_face_num],outputs=[model_output]).then(lambda: gr.Button(interactive=True), outputs=[gen_texture_button])gen_texture_button.click(run_texture,inputs=[image_prompts, model_output, seed],outputs=[textured_model_output])demo.load(start_session)demo.unload(end_session)demo.launch()
app.py+330-166