Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,11 @@
|
|
| 1 |
# Archive paper: https://arxiv.org/abs/2404.13000
|
| 2 |
|
| 3 |
import os
|
| 4 |
-
|
| 5 |
import gradio as gr
|
| 6 |
import matplotlib.pyplot as plt
|
| 7 |
import numpy as np
|
| 8 |
import skimage
|
| 9 |
-
|
| 10 |
import torch
|
| 11 |
|
| 12 |
from io_utils import LoadImageD
|
|
@@ -18,7 +17,6 @@ live_preds = None
|
|
| 18 |
|
| 19 |
def rotate_btn_fn(img, xt, yt, zt, add_bone_cmap=False):
|
| 20 |
global current_img
|
| 21 |
-
|
| 22 |
try:
|
| 23 |
angles = (xt, yt, zt)
|
| 24 |
print(f"Rotating with angles: {angles}")
|
|
@@ -33,10 +31,13 @@ def rotate_btn_fn(img, xt, yt, zt, add_bone_cmap=False):
|
|
| 33 |
|
| 34 |
out_img_path = f'data/cached_outputs/{os.path.basename(input_img_path)[:-4]}_{angles}.png'
|
| 35 |
|
|
|
|
| 36 |
if os.path.exists(out_img_path):
|
| 37 |
out_img = skimage.io.imread(out_img_path)
|
| 38 |
else:
|
| 39 |
-
|
|
|
|
|
|
|
| 40 |
|
| 41 |
if not add_bone_cmap:
|
| 42 |
return out_img
|
|
@@ -50,7 +51,7 @@ def rotate_btn_fn(img, xt, yt, zt, add_bone_cmap=False):
|
|
| 50 |
except Exception as e:
|
| 51 |
print(f"Error in rotate_btn_fn: {e}")
|
| 52 |
return None
|
| 53 |
-
|
| 54 |
css_style = "./style.css"
|
| 55 |
callback = gr.CSVLogger()
|
| 56 |
|
|
|
|
| 1 |
# Archive paper: https://arxiv.org/abs/2404.13000
|
| 2 |
|
| 3 |
import os
|
|
|
|
| 4 |
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
|
|
|
|
| 17 |
|
| 18 |
def rotate_btn_fn(img, xt, yt, zt, add_bone_cmap=False):
|
| 19 |
global current_img
|
|
|
|
| 20 |
try:
|
| 21 |
angles = (xt, yt, zt)
|
| 22 |
print(f"Rotating with angles: {angles}")
|
|
|
|
| 31 |
|
| 32 |
out_img_path = f'data/cached_outputs/{os.path.basename(input_img_path)[:-4]}_{angles}.png'
|
| 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
|
|
|
|
| 51 |
except Exception as e:
|
| 52 |
print(f"Error in rotate_btn_fn: {e}")
|
| 53 |
return None
|
| 54 |
+
|
| 55 |
css_style = "./style.css"
|
| 56 |
callback = gr.CSVLogger()
|
| 57 |
|