-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Kawaeee/v1.3
Refactor v1.3
- Loading branch information
Showing
12 changed files
with
304 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*.h5 | ||
.DS_Store | ||
__pycache__ | ||
datasets/ | ||
.python-version | ||
*.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.h5 | ||
.DS_Store | ||
__pycache__ | ||
datasets/ | ||
datasets/ | ||
.python-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,19 @@ | ||
FROM ubuntu:bionic | ||
LABEL maintainer="kawaekc@gmail.com" | ||
FROM python:3.9 | ||
|
||
ENV LANG=C.UTF-8 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV TZ=Asia/Bangkok | ||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | ||
|
||
# Update apt package | ||
RUN apt update --fix-missing | ||
# Allow statements and log messages to immediately appear in the logs | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Install required dependencies by default | ||
RUN apt install -y wget curl git htop nano | ||
WORKDIR /app | ||
|
||
# miniconda3 - Python 3.7 | ||
WORKDIR /opt/ | ||
ARG HOME="/opt" | ||
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py37_4.10.3-Linux-x86_64.sh \ | ||
&& bash Miniconda3-py37_4.10.3-Linux-x86_64.sh -b \ | ||
&& rm -r Miniconda3-py37_4.10.3-Linux-x86_64.sh | ||
ENV PATH="/opt/miniconda3/bin:${PATH}" | ||
COPY requirements.txt requirements.txt | ||
RUN pip install --no-cache-dir --upgrade -r requirements.txt | ||
|
||
# butt_or_bread repository | ||
RUN git clone https://github.com/Kawaeee/butt_or_bread.git | ||
COPY . . | ||
|
||
# Download model | ||
RUN cd /opt/butt_or_bread/ | ||
RUN wget https://github.com/Kawaeee/butt_or_bread/releases/download/v1.2/buttbread_resnet152_3.h5 | ||
RUN wget https://github.com/Kawaeee/butt_or_bread/releases/download/v1.3/buttbread_resnet152_3.h5 | ||
|
||
# Install python packages | ||
RUN pip install --upgrade pip | ||
RUN pip install -r /opt/butt_or_bread/requirements.txt --no-cache-dir | ||
|
||
# House-keeping | ||
RUN conda clean -a -y | ||
RUN pip cache purge | ||
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
RUN apt autoclean | ||
RUN apt autoremove | ||
|
||
ENV HOME="/root" | ||
|
||
ENTRYPOINT ["streamlit", "run", "/opt/butt_or_bread/streamlit_app.py"] | ||
ENTRYPOINT ["streamlit", "run", "/app/streamlit_app.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
import psutil | ||
|
||
|
||
def health_check(): | ||
"""Check CPU/Memory/Disk usage of deployed machine""" | ||
def health_check() -> str: | ||
""" | ||
Check the CPU, memory, and disk usage of the deployed machine. | ||
Returns: | ||
A string with information about the current usage levels for each resource, formatted as follows: | ||
"CPU Usage: [percent]%" | "Memory usage: [used memory]GB/[total memory]GB" | "Disk usage: [used disk]GB/[total disk]GB" | ||
Uses the `psutil` module to obtain information about the system resources. | ||
""" | ||
vm = psutil.virtual_memory() | ||
du = psutil.disk_usage("/") | ||
cpu_percent = psutil.cpu_percent(0.15) | ||
total_memory = psutil.virtual_memory().total / float(1 << 30) | ||
used_memory = psutil.virtual_memory().used / float(1 << 30) | ||
total_disk = psutil.disk_usage("/").total / float(1 << 30) | ||
used_disk = psutil.disk_usage("/").used / float(1 << 30) | ||
|
||
cpu_usage = f"CPU Usage: {cpu_percent:.2f}%" | ||
memory_usage = f"Memory usage: {used_memory:,.2f}G/{total_memory:,.2f}G" | ||
disk_usage = f"Disk usage: {used_disk:,.2f}G/{total_disk:,.2f}G" | ||
total_memory = vm.total / 1024**3 | ||
used_memory = vm.used / 1024**3 | ||
total_disk = du.total / 1024**3 | ||
used_disk = du.used / 1024**3 | ||
|
||
return " | ".join([cpu_usage, memory_usage, disk_usage]) | ||
return f"CPU Usage: {cpu_percent:.2f}% | Memory usage: {used_memory:.2f}GB/{total_memory:.2f}GB | Disk usage: {used_disk:.2f}GB/{total_disk:.2f}GB" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: "3.9" | ||
services: | ||
container: | ||
build: . | ||
ports: | ||
- "8501:8501" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
ImageHash==4.2.0 | ||
matplotlib==3.4.1 | ||
numpy==1.22.0 | ||
pillow==9.3.0 | ||
psutil==5.9.0 | ||
requests==2.27.1 | ||
streamlit==1.11.1 | ||
# [STREAMLIT-DEPLOYMENT-GUIDE] Add "+cpu" on torch and torchvision to get CPU inference support | ||
# NOTE: On macOS system, it might be unable to install with +cpu flag | ||
--find-links https://download.pytorch.org/whl/torch_stable.html | ||
torch==1.13.1 | ||
torchvision==0.9.1+cpu | ||
tqdm==4.60.0 | ||
streamlit==1.21.0 | ||
psutil==5.9.5 | ||
requests==2.28.2 | ||
torch==2.0.0 | ||
torchvision==0.15.1 | ||
Pillow==9.5.0 | ||
tqdm==4.65.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.