Spaces:
Sleeping
Sleeping
v1
Browse files- SandSnapModel.dockerfile.notes +12 -0
- app.py +10 -5
SandSnapModel.dockerfile.notes
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
FROM docker.io/library/python:3.8.9@sha256:49d05fff9cb3b185b15ffd92d8e6bd61c20aa916133dca2e3dbe0215270faf53
|
3 |
+
RUN sed -i 's http://deb.debian.org http://cdn-aws.deb.debian.org g' /etc/apt/sources.list && sed -i 's http://archive.ubuntu.com http://us-east-1.ec2.archive.ubuntu.com g' /etc/apt/sources.list && sed -i '/security/d' /etc/apt/sources.list && apt-get update && apt-get install -y git git-lfs ffmpeg libsm6 libxext6 cmake libgl1-mesa-glx && rm -rf /var/lib/apt/lists/* && git lfs install
|
4 |
+
RUN pip install --no-cache-dir pip==22.3.1 && pip install --no-cache-dir datasets "huggingface-hub>=0.12.1" "protobuf<4" "click<8.1"
|
5 |
+
RUN --mount=target=/root/packages.txt,source=packages.txt sed -i 's http://deb.debian.org http://cdn-aws.deb.debian.org g' /etc/apt/sources.list && sed -i 's http://archive.ubuntu.com http://us-east-1.ec2.archive.ubuntu.com g' /etc/apt/sources.list && sed -i '/security/d' /etc/apt/sources.list && apt-get update && xargs -r -a /root/packages.txt apt-get install -y && rm -rf /var/lib/apt/lists/*
|
6 |
+
WORKDIR /home/user/app
|
7 |
+
RUN useradd -m -u 1000 user
|
8 |
+
RUN --mount=target=pre-requirements.txt,source=pre-requirements.txt pip install --no-cache-dir -r pre-requirements.txt
|
9 |
+
RUN --mount=target=requirements.txt,source=requirements.txt pip install --no-cache-dir -r requirements.txt
|
10 |
+
RUN pip install --no-cache-dir gradio==3.28.3
|
11 |
+
COPY --link --chown=1000 --from=lfs /app /home/user/app
|
12 |
+
COPY --link --chown=1000 ./ /home/user/app
|
app.py
CHANGED
@@ -4,6 +4,8 @@
|
|
4 |
import gradio as gr
|
5 |
import numpy as np
|
6 |
import sys, json, os
|
|
|
|
|
7 |
sys.path.insert(1, 'app_files'+os.sep+'src')
|
8 |
from sedinet_eval import *
|
9 |
|
@@ -83,16 +85,18 @@ def grainsize(input_img, dims=(1024, 1024)):
|
|
83 |
|
84 |
result = estimate_siso_simo_1image(vars, input_img, greyscale,
|
85 |
dropout, weights_path)
|
86 |
-
|
|
|
87 |
result = np.array(result)
|
88 |
print(result)
|
89 |
-
|
90 |
plt.plot(np.hstack((result[:3], result[4:])),[10,16,25,50,65,75,84,90], 'k-o')
|
91 |
plt.xlabel('Grain size (pixels)')
|
92 |
plt.ylabel('Percent finer')
|
93 |
plt.savefig("psd.png", dpi=300, bbox_inches="tight")
|
94 |
|
95 |
-
|
|
|
96 |
|
97 |
title = "SandSnap/SediNet Model Demo- Measure grain size from image of sand!"
|
98 |
description = "Allows upload of imagery and download of grain size statistics. Statistics are unscaled (i.e. in pixels)"
|
@@ -104,9 +108,10 @@ examples = [
|
|
104 |
]
|
105 |
|
106 |
inp = gr.Image()
|
107 |
-
|
|
|
108 |
|
109 |
-
Segapp = gr.Interface(grainsize, inp, ["text", "text", out2], title = title, description = description, examples=examples)
|
110 |
#, allow_flagging='manual', flagging_options=["bad", "ok", "good", "perfect"], flagging_dir="flagged")
|
111 |
|
112 |
Segapp.launch(enable_queue=True)
|
|
|
4 |
import gradio as gr
|
5 |
import numpy as np
|
6 |
import sys, json, os
|
7 |
+
import pandas as pd
|
8 |
+
|
9 |
sys.path.insert(1, 'app_files'+os.sep+'src')
|
10 |
from sedinet_eval import *
|
11 |
|
|
|
85 |
|
86 |
result = estimate_siso_simo_1image(vars, input_img, greyscale,
|
87 |
dropout, weights_path)
|
88 |
+
result_str = [str(i)[:5] for i in result]
|
89 |
+
|
90 |
result = np.array(result)
|
91 |
print(result)
|
92 |
+
plt.clf()
|
93 |
plt.plot(np.hstack((result[:3], result[4:])),[10,16,25,50,65,75,84,90], 'k-o')
|
94 |
plt.xlabel('Grain size (pixels)')
|
95 |
plt.ylabel('Percent finer')
|
96 |
plt.savefig("psd.png", dpi=300, bbox_inches="tight")
|
97 |
|
98 |
+
|
99 |
+
return 'mean grain size = %f pixels' % (result[4]), '90th percentile grain size = %f pixels' % (result[-1]), plt, pd.DataFrame(data=result_str, index=['10','16','25','50','mean','65','75','84','90']).transpose(),
|
100 |
|
101 |
title = "SandSnap/SediNet Model Demo- Measure grain size from image of sand!"
|
102 |
description = "Allows upload of imagery and download of grain size statistics. Statistics are unscaled (i.e. in pixels)"
|
|
|
108 |
]
|
109 |
|
110 |
inp = gr.Image()
|
111 |
+
out1 = gr.Plot(type='matplotlib')
|
112 |
+
out2 = gr.Dataframe(label='Summary statistics', headers=['10','16','25','50','mean','65','75','84','90'], type='pandas')
|
113 |
|
114 |
+
Segapp = gr.Interface(grainsize, inp, ["text", "text", out1, out2], title = title, description = description, examples=examples)
|
115 |
#, allow_flagging='manual', flagging_options=["bad", "ok", "good", "perfect"], flagging_dir="flagged")
|
116 |
|
117 |
Segapp.launch(enable_queue=True)
|