Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -170,7 +170,7 @@ def find_the_most_recent_predict_path(path):
|
|
| 170 |
path = sorted(path, key=lambda x: x[-1])
|
| 171 |
return '/'.join(path[-1])
|
| 172 |
|
| 173 |
-
def Aspergillus_Detect():
|
| 174 |
# get_all_files(working_directory)
|
| 175 |
|
| 176 |
model = YOLO(weight_path) # pretrained YOLOv8n model
|
|
@@ -254,14 +254,14 @@ def Aspergillus_Detect():
|
|
| 254 |
|
| 255 |
"""# classify images: genus and Aspergillus"""
|
| 256 |
|
| 257 |
-
def classify_images(files):
|
| 258 |
print(f'threshold = {threshold}')
|
| 259 |
predict, result1 = genus_classify_images(files)
|
| 260 |
# # 列出工作目录及其子目录下的所有文件
|
| 261 |
# all_files = get_all_files(working_directory)
|
| 262 |
|
| 263 |
if predict == 'Aspergillus':
|
| 264 |
-
result2 = Aspergillus_Detect()
|
| 265 |
return f'{result1}\n\n{result2}'
|
| 266 |
return result1
|
| 267 |
|
|
@@ -302,13 +302,13 @@ def delete_folder(directory_path):
|
|
| 302 |
|
| 303 |
"""# main of gradio"""
|
| 304 |
|
| 305 |
-
threshold = 0.6
|
| 306 |
with gr.Blocks() as fungus_classification:
|
| 307 |
threshold = gr.Slider(minimum=0.1, maximum=1, step=0.1, value=0.6, label="Threshold", info="Choose between 0.1 and 1")
|
| 308 |
image_output = gr.Gallery(label = 'Images of Molds')
|
| 309 |
predict_outputs = gr.Textbox(label = 'Prediction Result')
|
| 310 |
upload_button = gr.UploadButton("Click to Upload Files", file_types=["image", "video"], file_count="multiple")
|
| 311 |
upload_button.upload(upload_file, upload_button, image_output)
|
| 312 |
-
upload_button.upload(classify_images, upload_button, predict_outputs)
|
| 313 |
# fungus_classification.launch(share=True, debug=True, enable_queue=True)
|
| 314 |
fungus_classification.launch(share=True, debug=True)
|
|
|
|
| 170 |
path = sorted(path, key=lambda x: x[-1])
|
| 171 |
return '/'.join(path[-1])
|
| 172 |
|
| 173 |
+
def Aspergillus_Detect(threshold):
|
| 174 |
# get_all_files(working_directory)
|
| 175 |
|
| 176 |
model = YOLO(weight_path) # pretrained YOLOv8n model
|
|
|
|
| 254 |
|
| 255 |
"""# classify images: genus and Aspergillus"""
|
| 256 |
|
| 257 |
+
def classify_images(files,threshold):
|
| 258 |
print(f'threshold = {threshold}')
|
| 259 |
predict, result1 = genus_classify_images(files)
|
| 260 |
# # 列出工作目录及其子目录下的所有文件
|
| 261 |
# all_files = get_all_files(working_directory)
|
| 262 |
|
| 263 |
if predict == 'Aspergillus':
|
| 264 |
+
result2 = Aspergillus_Detect(threshold)
|
| 265 |
return f'{result1}\n\n{result2}'
|
| 266 |
return result1
|
| 267 |
|
|
|
|
| 302 |
|
| 303 |
"""# main of gradio"""
|
| 304 |
|
| 305 |
+
# threshold = 0.6
|
| 306 |
with gr.Blocks() as fungus_classification:
|
| 307 |
threshold = gr.Slider(minimum=0.1, maximum=1, step=0.1, value=0.6, label="Threshold", info="Choose between 0.1 and 1")
|
| 308 |
image_output = gr.Gallery(label = 'Images of Molds')
|
| 309 |
predict_outputs = gr.Textbox(label = 'Prediction Result')
|
| 310 |
upload_button = gr.UploadButton("Click to Upload Files", file_types=["image", "video"], file_count="multiple")
|
| 311 |
upload_button.upload(upload_file, upload_button, image_output)
|
| 312 |
+
upload_button.upload(classify_images, [upload_button,threshold], predict_outputs)
|
| 313 |
# fungus_classification.launch(share=True, debug=True, enable_queue=True)
|
| 314 |
fungus_classification.launch(share=True, debug=True)
|