Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,6 @@ from huggingface_hub import snapshot_download
|
|
14 |
from flask_cors import CORS
|
15 |
import numpy as np
|
16 |
import trimesh
|
17 |
-
from rembg import remove
|
18 |
import sys
|
19 |
|
20 |
# Add SF3D code to sys.path
|
@@ -72,8 +71,6 @@ MAX_DIMENSION = 512 # SF3D expects 512x512
|
|
72 |
class TimeoutError(Exception):
|
73 |
pass
|
74 |
|
75 |
-
# Thread-safe=latin
|
76 |
-
|
77 |
# Thread-safe timeout implementation
|
78 |
def process_with_timeout(function, args, timeout):
|
79 |
result = [None]
|
@@ -107,7 +104,7 @@ def process_with_timeout(function, args, timeout):
|
|
107 |
def allowed_file(filename):
|
108 |
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
109 |
|
110 |
-
# Image preprocessing for SF3D (512x512)
|
111 |
def preprocess_image(image_path):
|
112 |
with Image.open(image_path) as img:
|
113 |
img = img.convert("RGB")
|
@@ -275,11 +272,8 @@ def convert_image_to_3d():
|
|
275 |
texture_sizes = {'low': 512, 'medium': 1024, 'high': 2048}
|
276 |
remesh_options = {'low': 0.5, 'medium': 1.0, 'high': 2.0}
|
277 |
|
278 |
-
#
|
279 |
-
|
280 |
-
|
281 |
-
# Convert to numpy
|
282 |
-
img_array = np.array(image_no_bg)
|
283 |
|
284 |
# Generate mesh
|
285 |
mesh = model(
|
@@ -438,10 +432,11 @@ def index():
|
|
438 |
"output_format": "glb",
|
439 |
"detail_level": "low, medium, or high - controls texture and mesh detail"
|
440 |
},
|
441 |
-
"description": "This API creates full 3D models from 2D images using Stable Fast 3D"
|
442 |
}), 200
|
443 |
|
444 |
if __name__ == '__main__':
|
445 |
cleanup_old_jobs()
|
446 |
port = int(os.environ.get('PORT', 7860))
|
447 |
-
app.run(host='0.0.0.0', port=port)
|
|
|
|
14 |
from flask_cors import CORS
|
15 |
import numpy as np
|
16 |
import trimesh
|
|
|
17 |
import sys
|
18 |
|
19 |
# Add SF3D code to sys.path
|
|
|
71 |
class TimeoutError(Exception):
|
72 |
pass
|
73 |
|
|
|
|
|
74 |
# Thread-safe timeout implementation
|
75 |
def process_with_timeout(function, args, timeout):
|
76 |
result = [None]
|
|
|
104 |
def allowed_file(filename):
|
105 |
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
106 |
|
107 |
+
# Image preprocessing for SF3D (512x512, no background removal)
|
108 |
def preprocess_image(image_path):
|
109 |
with Image.open(image_path) as img:
|
110 |
img = img.convert("RGB")
|
|
|
272 |
texture_sizes = {'low': 512, 'medium': 1024, 'high': 2048}
|
273 |
remesh_options = {'low': 0.5, 'medium': 1.0, 'high': 2.0}
|
274 |
|
275 |
+
# Convert image to numpy (no background removal)
|
276 |
+
img_array = np.array(image)
|
|
|
|
|
|
|
277 |
|
278 |
# Generate mesh
|
279 |
mesh = model(
|
|
|
432 |
"output_format": "glb",
|
433 |
"detail_level": "low, medium, or high - controls texture and mesh detail"
|
434 |
},
|
435 |
+
"description": "This API creates full 3D models from 2D images using Stable Fast 3D. Images should have transparent backgrounds."
|
436 |
}), 200
|
437 |
|
438 |
if __name__ == '__main__':
|
439 |
cleanup_old_jobs()
|
440 |
port = int(os.environ.get('PORT', 7860))
|
441 |
+
app.run(host='0.0.0.0', port=port)
|
442 |
+
```
|