Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,31 +3,40 @@ import numpy as np
|
|
3 |
|
4 |
# Define functions to wrap the private space's interfaces
|
5 |
def cataract_analyzer(image):
|
6 |
-
private_space_id = "EyeMedicalDiagnosis"
|
7 |
private_space = gr.Interface.load(private_space_id)
|
8 |
result = private_space(image)
|
9 |
-
|
10 |
-
return result
|
11 |
-
else:
|
12 |
-
return [np.zeros_like(image), "", np.zeros_like(image), 0, 0, 0, ""]
|
13 |
|
14 |
def glaucoma_analyzer(image):
|
15 |
-
private_space_id = "EyeMedicalDiagnosis"
|
16 |
private_space = gr.Interface.load(private_space_id)
|
17 |
result = private_space(image)
|
18 |
-
|
19 |
-
return result
|
20 |
-
else:
|
21 |
-
return [np.zeros_like(image), "", "", "", ""]
|
22 |
|
23 |
def rlfd_analyzer(image):
|
24 |
-
private_space_id = "EyeMedicalDiagnosis"
|
25 |
private_space = gr.Interface.load(private_space_id)
|
26 |
result = private_space(image)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
if isinstance(result, list) and len(result) == 8:
|
28 |
return result
|
29 |
else:
|
30 |
-
return [
|
31 |
|
32 |
# Create the public interface with custom layout
|
33 |
with gr.Blocks() as demo:
|
|
|
3 |
|
4 |
# Define functions to wrap the private space's interfaces
|
5 |
def cataract_analyzer(image):
|
6 |
+
private_space_id = "EyeMedicalDiagnosis/cataract_analyzer"
|
7 |
private_space = gr.Interface.load(private_space_id)
|
8 |
result = private_space(image)
|
9 |
+
return parse_cataract_result(result, image)
|
|
|
|
|
|
|
10 |
|
11 |
def glaucoma_analyzer(image):
|
12 |
+
private_space_id = "EyeMedicalDiagnosis/glaucoma_analyzer"
|
13 |
private_space = gr.Interface.load(private_space_id)
|
14 |
result = private_space(image)
|
15 |
+
return parse_glaucoma_result(result, image)
|
|
|
|
|
|
|
16 |
|
17 |
def rlfd_analyzer(image):
|
18 |
+
private_space_id = "EyeMedicalDiagnosis/rlfd_analyzer"
|
19 |
private_space = gr.Interface.load(private_space_id)
|
20 |
result = private_space(image)
|
21 |
+
return parse_rlfd_result(result, image)
|
22 |
+
|
23 |
+
def parse_cataract_result(result, image):
|
24 |
+
if isinstance(result, list) and len(result) == 7:
|
25 |
+
return result
|
26 |
+
else:
|
27 |
+
return [image, "Error: Invalid result", image, 0, 0, 0, ""]
|
28 |
+
|
29 |
+
def parse_glaucoma_result(result, image):
|
30 |
+
if isinstance(result, list) and len(result) == 5:
|
31 |
+
return result
|
32 |
+
else:
|
33 |
+
return [image, "Error: Invalid result", "0", "0", "0"]
|
34 |
+
|
35 |
+
def parse_rlfd_result(result, image):
|
36 |
if isinstance(result, list) and len(result) == 8:
|
37 |
return result
|
38 |
else:
|
39 |
+
return [image, image, "Error: Invalid result", image, "0", image, "0", image, "0"]
|
40 |
|
41 |
# Create the public interface with custom layout
|
42 |
with gr.Blocks() as demo:
|