Spaces:
Runtime error
Runtime error
testtest
Browse files
app.py
CHANGED
|
@@ -12,9 +12,9 @@ hybrid = None
|
|
| 12 |
|
| 13 |
|
| 14 |
def getDenseMask(landmarks, h, w):
|
| 15 |
-
RL = landmarks[0:
|
| 16 |
-
LL = landmarks[
|
| 17 |
-
H = landmarks[
|
| 18 |
|
| 19 |
img = np.zeros([h, w], dtype='uint8')
|
| 20 |
|
|
@@ -30,9 +30,9 @@ def getDenseMask(landmarks, h, w):
|
|
| 30 |
|
| 31 |
|
| 32 |
def getMasks(landmarks, h, w):
|
| 33 |
-
RL = landmarks[0:
|
| 34 |
-
LL = landmarks[
|
| 35 |
-
H = landmarks[
|
| 36 |
|
| 37 |
RL = RL.reshape(-1, 1, 2).astype('int')
|
| 38 |
LL = LL.reshape(-1, 1, 2).astype('int')
|
|
@@ -51,8 +51,8 @@ def getMasks(landmarks, h, w):
|
|
| 51 |
|
| 52 |
def calculate_image_tilt(landmarks):
|
| 53 |
"""Calculate image tilt angle based on lung symmetry"""
|
| 54 |
-
RL = landmarks[0:
|
| 55 |
-
LL = landmarks[
|
| 56 |
|
| 57 |
# Find the topmost points of both lungs
|
| 58 |
rl_top_idx = np.argmin(RL[:, 1])
|
|
@@ -98,7 +98,7 @@ def drawOnTop(img, landmarks, original_shape):
|
|
| 98 |
|
| 99 |
image = np.clip(image, 0, 1)
|
| 100 |
|
| 101 |
-
RL, LL, H = landmarks[0:
|
| 102 |
|
| 103 |
# Calculate image tilt and correct it for measurements
|
| 104 |
tilt_angle, rl_top, ll_top = calculate_image_tilt(landmarks)
|
|
@@ -297,9 +297,9 @@ def calculate_ctr(landmarks, corrected_landmarks=None):
|
|
| 297 |
if corrected_landmarks is not None:
|
| 298 |
RL, LL, H, tilt_angle = corrected_landmarks
|
| 299 |
else:
|
| 300 |
-
H = landmarks[
|
| 301 |
-
RL = landmarks[0:
|
| 302 |
-
LL = landmarks[
|
| 303 |
tilt_angle = 0
|
| 304 |
|
| 305 |
cardiac_width = np.max(H[:, 0]) - np.min(H[:, 0])
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
def getDenseMask(landmarks, h, w):
|
| 15 |
+
RL = landmarks[0:52]
|
| 16 |
+
LL = landmarks[52:110]
|
| 17 |
+
H = landmarks[110:]
|
| 18 |
|
| 19 |
img = np.zeros([h, w], dtype='uint8')
|
| 20 |
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
def getMasks(landmarks, h, w):
|
| 33 |
+
RL = landmarks[0:52]
|
| 34 |
+
LL = landmarks[52:110]
|
| 35 |
+
H = landmarks[110:]
|
| 36 |
|
| 37 |
RL = RL.reshape(-1, 1, 2).astype('int')
|
| 38 |
LL = LL.reshape(-1, 1, 2).astype('int')
|
|
|
|
| 51 |
|
| 52 |
def calculate_image_tilt(landmarks):
|
| 53 |
"""Calculate image tilt angle based on lung symmetry"""
|
| 54 |
+
RL = landmarks[0:52] # Right lung
|
| 55 |
+
LL = landmarks[52:110] # Left lung
|
| 56 |
|
| 57 |
# Find the topmost points of both lungs
|
| 58 |
rl_top_idx = np.argmin(RL[:, 1])
|
|
|
|
| 98 |
|
| 99 |
image = np.clip(image, 0, 1)
|
| 100 |
|
| 101 |
+
RL, LL, H = landmarks[0:52], landmarks[52:110], landmarks[110:]
|
| 102 |
|
| 103 |
# Calculate image tilt and correct it for measurements
|
| 104 |
tilt_angle, rl_top, ll_top = calculate_image_tilt(landmarks)
|
|
|
|
| 297 |
if corrected_landmarks is not None:
|
| 298 |
RL, LL, H, tilt_angle = corrected_landmarks
|
| 299 |
else:
|
| 300 |
+
H = landmarks[110:]
|
| 301 |
+
RL = landmarks[0:52]
|
| 302 |
+
LL = landmarks[52:110]
|
| 303 |
tilt_angle = 0
|
| 304 |
|
| 305 |
cardiac_width = np.max(H[:, 0]) - np.min(H[:, 0])
|