Spaces:
Runtime error
Runtime error
File size: 1,610 Bytes
b828b8f 0439cf9 b828b8f c192421 36a919c b828b8f c192421 36a919c b828b8f c192421 36a919c b828b8f 36a919c b828b8f 31bbd76 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import gradio as gr
import predict as predict
def upload_file(files):
file_paths = [file.name for file in files]
return file_paths
def process_file(webcam_filepath, upload_filepath):
result = []
if webcam_filepath == None:
sorted_classes = predict.predict_image(upload_filepath)
for class_label, class_prob in sorted_classes:
class_prob = class_prob.item().__round__(2)
result.append(f"{class_label}: {class_prob}%")
return result
elif upload_filepath == None:
sorted_classes = predict.predict_image(webcam_filepath)
for class_label, class_prob in sorted_classes:
class_prob = class_prob.item().__round__(2)
result.append(f"{class_label}: {class_prob}%")
return result
else:
sorted_classes = predict.predict_image(upload_filepath)
for class_label, class_prob in sorted_classes:
class_prob = class_prob.item().__round__(2)
result.append(f"{class_label}: {class_prob}%")
return result
demo = gr.Interface(
theme='gradio/soft',
fn=process_file,
title="HANDETECT",
description="An innovative AI-powered system that facilitates early detection and monitoring of movement disorders through handwriting assessment",
inputs=[
gr.inputs.Image(
source="upload", type="filepath", label="Choose Image"
),
],
outputs=[
gr.outputs.Textbox(label="Prediction 1"),
gr.outputs.Textbox(label="Prediction 2"),
gr.outputs.Textbox(label="Prediction 3"),
],
)
demo.launch()
|