Spaces:
Runtime error
Runtime error
Update worker_runpod.py
Browse files- worker_runpod.py +6 -4
worker_runpod.py
CHANGED
@@ -9,7 +9,6 @@ from diffusers.utils import load_image
|
|
9 |
from huggingface_hub import hf_hub_download
|
10 |
from src.utils.infer_util import remove_background, resize_foreground
|
11 |
|
12 |
-
import os, json
|
13 |
from torchvision.transforms import v2
|
14 |
from omegaconf import OmegaConf
|
15 |
from einops import repeat
|
@@ -21,7 +20,11 @@ from src.utils.train_util import instantiate_from_config
|
|
21 |
from src.utils.camera_util import (FOV_to_intrinsics, get_zero123plus_input_cameras,get_circular_camera_poses,)
|
22 |
from src.utils.mesh_util import save_obj, save_obj_with_mtl
|
23 |
|
24 |
-
import runpod
|
|
|
|
|
|
|
|
|
25 |
|
26 |
def preprocess(input_image, do_remove_background):
|
27 |
rembg_session = rembg.new_session() if do_remove_background else None
|
@@ -105,7 +108,6 @@ def make3d(images, model, device, IS_FLEXICUBES, infer_config, export_video, exp
|
|
105 |
images = images.unsqueeze(0).to(device)
|
106 |
images = v2.functional.resize(images, (320, 320), interpolation=3, antialias=True).clamp(0, 1)
|
107 |
mesh_fpath = tempfile.NamedTemporaryFile(suffix=f".obj", delete=False).name
|
108 |
-
print(mesh_fpath)
|
109 |
mesh_basename = os.path.basename(mesh_fpath).split('.')[0]
|
110 |
mesh_dirname = os.path.dirname(mesh_fpath)
|
111 |
video_fpath = os.path.join(mesh_dirname, f"{mesh_basename}.mp4")
|
@@ -150,7 +152,7 @@ def generate(input):
|
|
150 |
unet_ckpt_path = hf_hub_download(repo_id="TencentARC/InstantMesh", filename="diffusion_pytorch_model.bin", repo_type="model")
|
151 |
state_dict = torch.load(unet_ckpt_path, map_location='cpu')
|
152 |
pipeline.unet.load_state_dict(state_dict, strict=True)
|
153 |
-
device = torch.device('cuda
|
154 |
pipeline = pipeline.to(device)
|
155 |
seed_everything(0)
|
156 |
mv_images, mv_show_images = generate_mvs(processed_image, sample_steps, seed, pipeline, device)
|
|
|
9 |
from huggingface_hub import hf_hub_download
|
10 |
from src.utils.infer_util import remove_background, resize_foreground
|
11 |
|
|
|
12 |
from torchvision.transforms import v2
|
13 |
from omegaconf import OmegaConf
|
14 |
from einops import repeat
|
|
|
20 |
from src.utils.camera_util import (FOV_to_intrinsics, get_zero123plus_input_cameras,get_circular_camera_poses,)
|
21 |
from src.utils.mesh_util import save_obj, save_obj_with_mtl
|
22 |
|
23 |
+
import os, json, requests, runpod
|
24 |
+
|
25 |
+
discord_token = os.getenv('com_camenduru_discord_token')
|
26 |
+
web_uri = os.getenv('com_camenduru_web_uri')
|
27 |
+
web_token = os.getenv('com_camenduru_web_token')
|
28 |
|
29 |
def preprocess(input_image, do_remove_background):
|
30 |
rembg_session = rembg.new_session() if do_remove_background else None
|
|
|
108 |
images = images.unsqueeze(0).to(device)
|
109 |
images = v2.functional.resize(images, (320, 320), interpolation=3, antialias=True).clamp(0, 1)
|
110 |
mesh_fpath = tempfile.NamedTemporaryFile(suffix=f".obj", delete=False).name
|
|
|
111 |
mesh_basename = os.path.basename(mesh_fpath).split('.')[0]
|
112 |
mesh_dirname = os.path.dirname(mesh_fpath)
|
113 |
video_fpath = os.path.join(mesh_dirname, f"{mesh_basename}.mp4")
|
|
|
152 |
unet_ckpt_path = hf_hub_download(repo_id="TencentARC/InstantMesh", filename="diffusion_pytorch_model.bin", repo_type="model")
|
153 |
state_dict = torch.load(unet_ckpt_path, map_location='cpu')
|
154 |
pipeline.unet.load_state_dict(state_dict, strict=True)
|
155 |
+
device = torch.device('cuda')
|
156 |
pipeline = pipeline.to(device)
|
157 |
seed_everything(0)
|
158 |
mv_images, mv_show_images = generate_mvs(processed_image, sample_steps, seed, pipeline, device)
|