Spaces:
Runtime error
Runtime error
Feat: append json result rendering and new examples
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
"""
|
| 2 |
-
|
| 3 |
Original Algorithm:
|
| 4 |
- https://github.com/GreenCUBIC/AudiogramDigitization
|
| 5 |
|
|
@@ -28,7 +27,6 @@ from digitizer.digitization import generate_partial_annotation, extract_threshol
|
|
| 28 |
|
| 29 |
EXAMPLES_PATH = Path('./examples')
|
| 30 |
|
| 31 |
-
|
| 32 |
max_length = 5
|
| 33 |
img_width = 200
|
| 34 |
img_height = 50
|
|
@@ -78,22 +76,18 @@ def plot_audiogram(digital_result):
|
|
| 78 |
plt.plot(selection.frequency, selection.threshold, color="red" if ear == "right" else "blue", linewidth=0.5)
|
| 79 |
|
| 80 |
return plt.gcf()
|
| 81 |
-
# Save audiogram plot to nparray
|
| 82 |
-
# get image as np.array
|
| 83 |
-
# canvas = plt.gca().figure.canvas
|
| 84 |
-
# canvas.draw()
|
| 85 |
-
# image = np.frombuffer(canvas.tostring_rgb(), dtype=np.uint8)
|
| 86 |
-
# return Image.fromarray(image)
|
| 87 |
-
|
| 88 |
|
| 89 |
# Function for Audiogram Digit Recognition
|
| 90 |
def audiogram_digit_recognition(img_path):
|
| 91 |
digital_result = extract_thresholds(img_path, gpu=False)
|
| 92 |
-
return plot_audiogram(digital_result)
|
| 93 |
|
| 94 |
|
| 95 |
-
output = gr.Plot()
|
| 96 |
-
examples = [
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
iface = gr.Interface(
|
| 99 |
fn=audiogram_digit_recognition,
|
|
|
|
| 1 |
"""
|
|
|
|
| 2 |
Original Algorithm:
|
| 3 |
- https://github.com/GreenCUBIC/AudiogramDigitization
|
| 4 |
|
|
|
|
| 27 |
|
| 28 |
EXAMPLES_PATH = Path('./examples')
|
| 29 |
|
|
|
|
| 30 |
max_length = 5
|
| 31 |
img_width = 200
|
| 32 |
img_height = 50
|
|
|
|
| 76 |
plt.plot(selection.frequency, selection.threshold, color="red" if ear == "right" else "blue", linewidth=0.5)
|
| 77 |
|
| 78 |
return plt.gcf()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
# Function for Audiogram Digit Recognition
|
| 81 |
def audiogram_digit_recognition(img_path):
|
| 82 |
digital_result = extract_thresholds(img_path, gpu=False)
|
| 83 |
+
return [plot_audiogram(digital_result), digital_result]
|
| 84 |
|
| 85 |
|
| 86 |
+
output = [gr.Plot(), gr.JSON()]
|
| 87 |
+
examples = [
|
| 88 |
+
f'{EXAMPLES_PATH}/audiogram_example01.png',
|
| 89 |
+
f'{EXAMPLES_PATH}/audiogram_example02.png'
|
| 90 |
+
]
|
| 91 |
|
| 92 |
iface = gr.Interface(
|
| 93 |
fn=audiogram_digit_recognition,
|