Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,8 +5,7 @@ import gradio as gr
|
|
5 |
import matplotlib.pyplot as plt
|
6 |
import numpy as np
|
7 |
import skimage
|
8 |
-
from skimage import io
|
9 |
-
import torch
|
10 |
|
11 |
from io_utils import LoadImageD
|
12 |
|
@@ -15,6 +14,17 @@ from io_utils import LoadImageD
|
|
15 |
current_img = None
|
16 |
live_preds = None
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
def rotate_btn_fn(img, xt, yt, zt, add_bone_cmap=False):
|
19 |
global current_img
|
20 |
try:
|
@@ -26,18 +36,12 @@ def rotate_btn_fn(img, xt, yt, zt, add_bone_cmap=False):
|
|
26 |
skimage.io.imsave(input_img_path, img)
|
27 |
elif isinstance(img, str) and os.path.exists(img):
|
28 |
input_img_path = img
|
|
|
29 |
else:
|
30 |
raise ValueError("Invalid input image")
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
# Assuming you have precomputed outputs for the example images
|
35 |
-
if os.path.exists(out_img_path):
|
36 |
-
out_img = skimage.io.imread(out_img_path)
|
37 |
-
else:
|
38 |
-
# Perform your rotation here if the precomputed image doesn't exist
|
39 |
-
# For now, let's just return the input image for demonstration purposes
|
40 |
-
out_img = img
|
41 |
|
42 |
if not add_bone_cmap:
|
43 |
return out_img
|
|
|
5 |
import matplotlib.pyplot as plt
|
6 |
import numpy as np
|
7 |
import skimage
|
8 |
+
from skimage import io, transform
|
|
|
9 |
|
10 |
from io_utils import LoadImageD
|
11 |
|
|
|
14 |
current_img = None
|
15 |
live_preds = None
|
16 |
|
17 |
+
def rotate_img(image, angles):
|
18 |
+
"""Rotate the input image based on the given angles."""
|
19 |
+
xt, yt, zt = angles
|
20 |
+
|
21 |
+
# Apply rotations (this is just a placeholder, replace with your actual logic)
|
22 |
+
rotated_img = skimage.transform.rotate(image, angle=xt, mode='edge')
|
23 |
+
rotated_img = skimage.transform.rotate(rotated_img, angle=yt, mode='edge')
|
24 |
+
rotated_img = skimage.transform.rotate(rotated_img, angle=zt, mode='edge')
|
25 |
+
|
26 |
+
return rotated_img
|
27 |
+
|
28 |
def rotate_btn_fn(img, xt, yt, zt, add_bone_cmap=False):
|
29 |
global current_img
|
30 |
try:
|
|
|
36 |
skimage.io.imsave(input_img_path, img)
|
37 |
elif isinstance(img, str) and os.path.exists(img):
|
38 |
input_img_path = img
|
39 |
+
img = skimage.io.imread(input_img_path)
|
40 |
else:
|
41 |
raise ValueError("Invalid input image")
|
42 |
|
43 |
+
# Apply the rotation
|
44 |
+
out_img = rotate_img(img, angles)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
if not add_bone_cmap:
|
47 |
return out_img
|