Spaces:
Sleeping
Sleeping
Commit ·
d29fe27
1
Parent(s): 5dc183f
Initial commit
Browse files- README.md +1 -0
- app.py +48 -0
- requirements.txt +5 -0
README.md
CHANGED
|
@@ -7,6 +7,7 @@ sdk: gradio
|
|
| 7 |
sdk_version: 6.10.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
|
|
|
| 10 |
short_description: Maturation status of P. lamprey using ultrasound from MY22-2
|
| 11 |
---
|
| 12 |
|
|
|
|
| 7 |
sdk_version: 6.10.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
python_version: 3.14.0
|
| 11 |
short_description: Maturation status of P. lamprey using ultrasound from MY22-2
|
| 12 |
---
|
| 13 |
|
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
|
| 4 |
+
from huggingface_hub import from_pretrained_fastai
|
| 5 |
+
|
| 6 |
+
learn = from_pretrained_fastai("lmedeirosUI/MatStat_Oct22")
|
| 7 |
+
|
| 8 |
+
labels = learn.dls.vocab
|
| 9 |
+
def predict(img):
|
| 10 |
+
img = PILImage.create(img)
|
| 11 |
+
pred, pred_idx,probs = learn.predict(img)
|
| 12 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 13 |
+
|
| 14 |
+
#predict('test.jpg') # test
|
| 15 |
+
|
| 16 |
+
title = "<p style='text-align: center; font-size: 25px; font-weight: bold'>Maturation Status App for Pacific lamprey</p>"
|
| 17 |
+
description = "<p style='text-align: center; font-size: 20px'>Upload an ultrasound image to determine the maturation status of a Pacific lamprey</p>"
|
| 18 |
+
article="<p style='text-align: center'>App & MLM created by Lea R. Medeiros</p><p style='text-align: center'><a href='https://critfc.org/fish-and-watersheds/columbia-river-fish-species/lamprey/pacific-lamprey-restoration/' target='_blank'>Pacific Lamprey Restoration Efforts at CRITFC</a></p><p style='text-align: center'><a href='https://www.pacificlamprey.org' target='_blank'>Pacific Lamprey Conservation Initiative</a></p>"
|
| 19 |
+
|
| 20 |
+
#SexID = gr.Interface(fn=predict, inputs=gr.Image(height=512, width=512), outputs=gr.Label(num_top_classes=2), title=title, description=description, examples=examples, article=article)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
with gr.Blocks() as MatStat_Oct22:
|
| 24 |
+
gr.Markdown(title)
|
| 25 |
+
gr.Markdown(description)
|
| 26 |
+
with gr.Row():
|
| 27 |
+
with gr.Column(scale=1):
|
| 28 |
+
with gr.Row():
|
| 29 |
+
gr.Markdown("<p style='text-align: center; font-size: 15px'>Upload an ultrasound image (ideally taken in the fall following collection) to the Input area and click the <span style='font-weight: bold'>Run</span> button. To upload another image, click the <span style='font-weight: bold'>Clear</span> button</p>")
|
| 30 |
+
with gr.Row():
|
| 31 |
+
inp = gr.Image(height = 430, label="Input image")
|
| 32 |
+
with gr.Column(scale=1):
|
| 33 |
+
with gr.Row():
|
| 34 |
+
out = gr.Label(num_top_classes=4, label="Maturation Status Prediction")
|
| 35 |
+
with gr.Row():
|
| 36 |
+
btn1 = gr.Button("Run", variant="primary")
|
| 37 |
+
btn1.click(fn=predict, inputs=inp, outputs=out)
|
| 38 |
+
with gr.Row():
|
| 39 |
+
gr.ClearButton([inp, out], variant="secondary")
|
| 40 |
+
with gr.Row():
|
| 41 |
+
gr.Markdown("<p style='text-align: center'>Example images - just drag and drop into the input area and click the <span style='font-weight: bold'>Run</span> button</p>")
|
| 42 |
+
with gr.Row():
|
| 43 |
+
gr.Image("test.JPG", scale=1, label="Example 1")
|
| 44 |
+
gr.Image("test2.JPG", scale=1, label="Example 2")
|
| 45 |
+
with gr.Row():
|
| 46 |
+
gr.Markdown(article)
|
| 47 |
+
|
| 48 |
+
MatStat_Oct22.launch(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("IBM Plex Sans"), "Arial", "sans-serif"]), ssr_mode=False)
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai
|
| 2 |
+
scikit-image
|
| 3 |
+
IPython
|
| 4 |
+
toml
|
| 5 |
+
gradio
|