Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -98,14 +98,15 @@ infer_config = config.infer_config
|
|
| 98 |
|
| 99 |
IS_FLEXICUBES = True if config_name.startswith('instant-mesh') else False
|
| 100 |
|
| 101 |
-
|
|
|
|
| 102 |
|
| 103 |
# load diffusion model
|
| 104 |
print('Loading diffusion model ...')
|
| 105 |
pipeline = DiffusionPipeline.from_pretrained(
|
| 106 |
"sudo-ai/zero123plus-v1.2",
|
| 107 |
custom_pipeline="zero123plus",
|
| 108 |
-
torch_dtype=torch.
|
| 109 |
)
|
| 110 |
pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(
|
| 111 |
pipeline.scheduler.config, timestep_spacing='trailing'
|
|
@@ -137,7 +138,6 @@ def check_input_image(input_image):
|
|
| 137 |
|
| 138 |
|
| 139 |
def preprocess(input_image, do_remove_background):
|
| 140 |
-
|
| 141 |
rembg_session = rembg.new_session() if do_remove_background else None
|
| 142 |
|
| 143 |
if do_remove_background:
|
|
@@ -147,9 +147,7 @@ def preprocess(input_image, do_remove_background):
|
|
| 147 |
return input_image
|
| 148 |
|
| 149 |
|
| 150 |
-
@spaces.GPU
|
| 151 |
def generate_mvs(input_image, sample_steps, sample_seed):
|
| 152 |
-
|
| 153 |
seed_everything(sample_seed)
|
| 154 |
|
| 155 |
# sampling
|
|
@@ -167,9 +165,7 @@ def generate_mvs(input_image, sample_steps, sample_seed):
|
|
| 167 |
return z123_image, show_image
|
| 168 |
|
| 169 |
|
| 170 |
-
@spaces.GPU
|
| 171 |
def make3d(images):
|
| 172 |
-
|
| 173 |
global model
|
| 174 |
if IS_FLEXICUBES:
|
| 175 |
model.init_flexicubes_geometry(device, use_renderer=False)
|
|
|
|
| 98 |
|
| 99 |
IS_FLEXICUBES = True if config_name.startswith('instant-mesh') else False
|
| 100 |
|
| 101 |
+
# Set device to CPU
|
| 102 |
+
device = torch.device('cpu')
|
| 103 |
|
| 104 |
# load diffusion model
|
| 105 |
print('Loading diffusion model ...')
|
| 106 |
pipeline = DiffusionPipeline.from_pretrained(
|
| 107 |
"sudo-ai/zero123plus-v1.2",
|
| 108 |
custom_pipeline="zero123plus",
|
| 109 |
+
torch_dtype=torch.float32, # Changed from float16 to float32 for CPU
|
| 110 |
)
|
| 111 |
pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(
|
| 112 |
pipeline.scheduler.config, timestep_spacing='trailing'
|
|
|
|
| 138 |
|
| 139 |
|
| 140 |
def preprocess(input_image, do_remove_background):
|
|
|
|
| 141 |
rembg_session = rembg.new_session() if do_remove_background else None
|
| 142 |
|
| 143 |
if do_remove_background:
|
|
|
|
| 147 |
return input_image
|
| 148 |
|
| 149 |
|
|
|
|
| 150 |
def generate_mvs(input_image, sample_steps, sample_seed):
|
|
|
|
| 151 |
seed_everything(sample_seed)
|
| 152 |
|
| 153 |
# sampling
|
|
|
|
| 165 |
return z123_image, show_image
|
| 166 |
|
| 167 |
|
|
|
|
| 168 |
def make3d(images):
|
|
|
|
| 169 |
global model
|
| 170 |
if IS_FLEXICUBES:
|
| 171 |
model.init_flexicubes_geometry(device, use_renderer=False)
|