Spaces:
Runtime error
Runtime error
lionelgarnier
commited on
Commit
·
ac52c1d
1
Parent(s):
2b694f3
update preprocess_image to handle numpy arrays and improve image conversion
Browse files
app.py
CHANGED
@@ -62,11 +62,16 @@ def end_session(req: gr.Request):
|
|
62 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
63 |
shutil.rmtree(user_dir)
|
64 |
|
65 |
-
def preprocess_image(image
|
66 |
trellis = get_trellis_pipeline()
|
67 |
if trellis is None:
|
68 |
# If the pipeline is not loaded, just return the original image
|
69 |
return image
|
|
|
|
|
|
|
|
|
|
|
70 |
# trellis.cuda()
|
71 |
processed_image = trellis.preprocess_image(image)
|
72 |
return processed_image
|
|
|
62 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
63 |
shutil.rmtree(user_dir)
|
64 |
|
65 |
+
def preprocess_image(image):
|
66 |
trellis = get_trellis_pipeline()
|
67 |
if trellis is None:
|
68 |
# If the pipeline is not loaded, just return the original image
|
69 |
return image
|
70 |
+
|
71 |
+
# Check if image is a numpy array and convert to PIL Image if needed
|
72 |
+
if isinstance(image, np.ndarray):
|
73 |
+
image = Image.fromarray(image.astype('uint8'))
|
74 |
+
|
75 |
# trellis.cuda()
|
76 |
processed_image = trellis.preprocess_image(image)
|
77 |
return processed_image
|