Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,7 +22,6 @@ import io
|
|
| 22 |
from io import BytesIO
|
| 23 |
from botocore.exceptions import NoCredentialsError, PartialCredentialsError
|
| 24 |
|
| 25 |
-
torch.cuda.empty_cache()
|
| 26 |
|
| 27 |
app = FastAPI()
|
| 28 |
|
|
@@ -40,7 +39,8 @@ if torch.cuda.is_available():
|
|
| 40 |
device = "cuda:0"
|
| 41 |
else:
|
| 42 |
device = "cpu"
|
| 43 |
-
|
|
|
|
| 44 |
|
| 45 |
model = TSR.from_pretrained(
|
| 46 |
"stabilityai/TripoSR",
|
|
@@ -182,8 +182,7 @@ def preprocess(input_image, do_remove_background, foreground_ratio):
|
|
| 182 |
|
| 183 |
# @spaces.GPU
|
| 184 |
def generate(image, mc_resolution, formats=["obj", "glb"]):
|
| 185 |
-
torch.cuda.
|
| 186 |
-
torch.cuda.empty_cache()
|
| 187 |
scene_codes = model(image, device=device)
|
| 188 |
mesh = model.extract_mesh(scene_codes, resolution=mc_resolution)[0]
|
| 189 |
mesh = to_gradio_3d_orientation(mesh)
|
|
@@ -194,9 +193,6 @@ def generate(image, mc_resolution, formats=["obj", "glb"]):
|
|
| 194 |
mesh_path_obj = tempfile.NamedTemporaryFile(suffix=f".obj", delete=False)
|
| 195 |
mesh.apply_scale([-1, 1, 1]) # Otherwise the visualized .obj will be flipped
|
| 196 |
mesh.export(mesh_path_obj.name)
|
| 197 |
-
|
| 198 |
-
torch.cuda.synchronize()
|
| 199 |
-
|
| 200 |
return mesh_path_obj.name, mesh_path_glb.name
|
| 201 |
|
| 202 |
def upload_file_to_s3(file_path, bucket_name, object_name=None):
|
|
|
|
| 22 |
from io import BytesIO
|
| 23 |
from botocore.exceptions import NoCredentialsError, PartialCredentialsError
|
| 24 |
|
|
|
|
| 25 |
|
| 26 |
app = FastAPI()
|
| 27 |
|
|
|
|
| 39 |
device = "cuda:0"
|
| 40 |
else:
|
| 41 |
device = "cpu"
|
| 42 |
+
|
| 43 |
+
torch.cuda.synchronize()
|
| 44 |
|
| 45 |
model = TSR.from_pretrained(
|
| 46 |
"stabilityai/TripoSR",
|
|
|
|
| 182 |
|
| 183 |
# @spaces.GPU
|
| 184 |
def generate(image, mc_resolution, formats=["obj", "glb"]):
|
| 185 |
+
# torch.cuda.empty_cache()
|
|
|
|
| 186 |
scene_codes = model(image, device=device)
|
| 187 |
mesh = model.extract_mesh(scene_codes, resolution=mc_resolution)[0]
|
| 188 |
mesh = to_gradio_3d_orientation(mesh)
|
|
|
|
| 193 |
mesh_path_obj = tempfile.NamedTemporaryFile(suffix=f".obj", delete=False)
|
| 194 |
mesh.apply_scale([-1, 1, 1]) # Otherwise the visualized .obj will be flipped
|
| 195 |
mesh.export(mesh_path_obj.name)
|
|
|
|
|
|
|
|
|
|
| 196 |
return mesh_path_obj.name, mesh_path_glb.name
|
| 197 |
|
| 198 |
def upload_file_to_s3(file_path, bucket_name, object_name=None):
|