Spaces:
Sleeping
Sleeping
AI-RESEARCHER-2024
commited on
Commit
•
4982838
1
Parent(s):
fbb863a
Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,6 @@ class ModelManager:
|
|
35 |
else:
|
36 |
return load_model(model_path)
|
37 |
|
38 |
-
|
39 |
class ImageProcessor:
|
40 |
|
41 |
def process_image(self, image: Image.Image, model_name: str):
|
@@ -119,7 +118,6 @@ class ImageProcessor:
|
|
119 |
img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
|
120 |
return img
|
121 |
|
122 |
-
|
123 |
class GradioInterface:
|
124 |
def __init__(self):
|
125 |
self.image_processor = ImageProcessor()
|
@@ -261,16 +259,6 @@ class GradioInterface:
|
|
261 |
</div>
|
262 |
"""
|
263 |
|
264 |
-
header_html = f"""
|
265 |
-
<div class="app-header">
|
266 |
-
<h1 class="app-title">AI in Dentistry</h1>
|
267 |
-
<h2 class="app-subtitle"> Advancing Imaging and Clinical Transcription</h2>
|
268 |
-
<p class="app-description">
|
269 |
-
This application demonstrates the use of AI in dentistry for tasks such as classification, detection, and segmentation.
|
270 |
-
</p>
|
271 |
-
</div>
|
272 |
-
"""
|
273 |
-
|
274 |
js_func = """
|
275 |
function refresh() {
|
276 |
const url = new URL(window.location);
|
@@ -300,10 +288,21 @@ class GradioInterface:
|
|
300 |
choices=list(Config.MODELS.keys()),
|
301 |
value="Calculus and Caries Classification",
|
302 |
)
|
303 |
-
|
|
|
304 |
inputs=input_image,
|
305 |
examples=self.preloaded_examples["Calculus and Caries Classification"],
|
306 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
with gr.Column():
|
308 |
result = gr.Image(label="Result", elem_classes="image-preview")
|
309 |
run_button = gr.Button("Run", elem_classes="gr-button")
|
@@ -311,7 +310,7 @@ class GradioInterface:
|
|
311 |
model_name.change(
|
312 |
fn=update_examples,
|
313 |
inputs=model_name,
|
314 |
-
outputs=
|
315 |
)
|
316 |
|
317 |
run_button.click(
|
@@ -328,5 +327,4 @@ def main():
|
|
328 |
demo.launch(share=False)
|
329 |
|
330 |
if __name__ == "__main__":
|
331 |
-
main()
|
332 |
-
|
|
|
35 |
else:
|
36 |
return load_model(model_path)
|
37 |
|
|
|
38 |
class ImageProcessor:
|
39 |
|
40 |
def process_image(self, image: Image.Image, model_name: str):
|
|
|
118 |
img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
|
119 |
return img
|
120 |
|
|
|
121 |
class GradioInterface:
|
122 |
def __init__(self):
|
123 |
self.image_processor = ImageProcessor()
|
|
|
259 |
</div>
|
260 |
"""
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
js_func = """
|
263 |
function refresh() {
|
264 |
const url = new URL(window.location);
|
|
|
288 |
choices=list(Config.MODELS.keys()),
|
289 |
value="Calculus and Caries Classification",
|
290 |
)
|
291 |
+
examples_classification = gr.Examples(
|
292 |
+
label="Classification Examples",
|
293 |
inputs=input_image,
|
294 |
examples=self.preloaded_examples["Calculus and Caries Classification"],
|
295 |
)
|
296 |
+
examples_detection = gr.Examples(
|
297 |
+
label="Caries Detection Examples",
|
298 |
+
inputs=input_image,
|
299 |
+
examples=self.preloaded_examples["Caries Detection"],
|
300 |
+
)
|
301 |
+
examples_segmentation = gr.Examples(
|
302 |
+
label="Segmentation Examples",
|
303 |
+
inputs=input_image,
|
304 |
+
examples=self.preloaded_examples["Dental X-Ray Segmentation"],
|
305 |
+
)
|
306 |
with gr.Column():
|
307 |
result = gr.Image(label="Result", elem_classes="image-preview")
|
308 |
run_button = gr.Button("Run", elem_classes="gr-button")
|
|
|
310 |
model_name.change(
|
311 |
fn=update_examples,
|
312 |
inputs=model_name,
|
313 |
+
outputs=[examples_classification.dataset, examples_detection.dataset, examples_segmentation.dataset],
|
314 |
)
|
315 |
|
316 |
run_button.click(
|
|
|
327 |
demo.launch(share=False)
|
328 |
|
329 |
if __name__ == "__main__":
|
330 |
+
main()
|
|