Deploy pytorch classification model using Flask and Streamlit

Overview

Tomato Disease Classification Model Deploy




1. Streamlit이란?

  • 데모 형식으로 웹을 만들 수 있는 프레임워크
  • 단점 : Interactive (파라미터, input shape, batch size 등 사용자가 화면에서 선택 할 경우) 한 동작이 발생 할 경우 새로 고침이 됨 -> form과 submit 이용해야 함



2. How to run

1-1) 플라스크 API 서버 (모델 서빙) : python flask_server.py
  • 터미널을 열어 플라스크 API 서버 (모델 서빙)을 먼저 실행 합니다.
1-2) (Option) 플라스크 API 서버 (모델 서빙) 테스트 : python flask_test.py
  • '필요 시' 터미널을 열어 플라스크 API 서버 (모델 서빙)을 테스트 합니다.
2-1) Streamlit : streamlit run streamlit.py
  • 터미널을 열어 Stremlit으로 개발 된 데모 웹 페이지를 실행 합니다.
2-2) 사용자는 http://127.0.0.1:5000/으로 웹 페이지에 접근 가능 합니다.



3. DIR 구조 설명

  • inference/ : 인퍼런스가 진행 되는 로직입니다. (학습 된 모델을 폴더 구조에 넣어 두고 > 모델을 미리 정의 해 둔 틀에 끼워서 로드 한 후 > 정규화 해서 > 요청이 들어 올 때 마다 결과 출력 하여 반환)
  • inference_image/ : 인퍼런스 할 이미지를 담는 곳입니다. (테스트 용)
  • model/ : 학습 된 모델 '틀'을 담는 곳입니다.
  • trained_model/ : 학습 된 모델을 담는 곳입니다.
  • flask_server.py : 플라스크 API 서버 (모델 서빙) 실행 파일
  • flask_test.py : 플라스크 API 서버 (모델 서빙) 테스트 파일
  • requirements.txt : 필요 라이브러리 설치
  • streamlit.py : 스트림릿 데모 웹 페이지



4. 프로젝트 진행 순서

1) 토마토 잎 분류 best 모델 저장
2) 플라스크 API 서버 (모델 서빙) 개발
3) 플라스크 API 서버 (모델 서빙) 테스트
4) 스트림릿 데모 웹 페이지 개발



5. 아키텍쳐 설명

1) 인퍼런스 로직 (PyTorch)
  • 학습 된 모델 로드 (나의 best 모델을 로컬 특정 폴더에 위치 시키기!)
  • 인풋 이미지 정규화
  • Request 발생 시 인퍼런스 결과 반환

2) 모델 서빙 (Flask)
  • Request 이미지 파일
  • 인퍼런스 로직 적용
  • 요청이 들어 올 때 마다 인퍼런스 결과 반환

3) 웹 페이지 (Streamlit)
  • 사용자가 이미지 업로드
  • 플라스크 API 서버로 이미지 request
  • 인퍼런스 진행 된 response 결과 파싱
  • Streamlit 화면에 뿌림



6. 기타

  • 여러 데이터를 한 번에 인퍼런스 할 경우 고려하기
  • 인퍼런스가 돌 때 추가 호출이 올 경우 고려하기
  • 배치성, 실시간성, 큐에 넣고 한 번에 동작 등 여러 시나리오 고려 하기
Owner
Ben Seo
데린이
Ben Seo
Build fully-functioning computer vision models with PyTorch

Detecto is a Python package that allows you to build fully-functioning computer vision and object detection models with just 5 lines of code. Inferenc

Alan Bi 576 Dec 29, 2022
SpiroMask: Measuring Lung Function Using Consumer-Grade Masks

SpiroMask: Measuring Lung Function Using Consumer-Grade Masks Anonymised repository for paper submitted for peer review at ACM HEALTH (October 2021).

0 May 10, 2022
Computationally Efficient Optimization of Plackett-Luce Ranking Models for Relevance and Fairness

Computationally Efficient Optimization of Plackett-Luce Ranking Models for Relevance and Fairness This repository contains the code used for the exper

H.R. Oosterhuis 28 Nov 29, 2022
Finding Donors for CharityML

Finding-Donors-for-CharityML - Investigated factors that affect the likelihood of charity donations being made based on real census data.

Moamen Abdelkawy 1 Dec 30, 2021
Implementation of the algorithm shown in the article "Modelo de Predicción de Éxito de Canciones Basado en Descriptores de Audio"

Success Predictor Implementation of the algorithm shown in the article "Modelo de Predicción de Éxito de Canciones Basado en Descriptores de Audio". B

Rodrigo Nazar Meier 4 Mar 17, 2022
[ICCV' 21] "Unsupervised Point Cloud Pre-training via Occlusion Completion"

OcCo: Unsupervised Point Cloud Pre-training via Occlusion Completion This repository is the official implementation of paper: "Unsupervised Point Clou

Hanchen 204 Dec 24, 2022
git《USD-Seg:Learning Universal Shape Dictionary for Realtime Instance Segmentation》(2020) GitHub: [fig2]

USD-Seg This project is an implement of paper USD-Seg:Learning Universal Shape Dictionary for Realtime Instance Segmentation, based on FCOS detector f

Ruolin Ye 80 Nov 28, 2022
The official pytorch implementation of our paper "Is Space-Time Attention All You Need for Video Understanding?"

TimeSformer This is an official pytorch implementation of Is Space-Time Attention All You Need for Video Understanding?. In this repository, we provid

Facebook Research 1k Dec 31, 2022
SeqFormer: a Frustratingly Simple Model for Video Instance Segmentation

SeqFormer: a Frustratingly Simple Model for Video Instance Segmentation SeqFormer SeqFormer: a Frustratingly Simple Model for Video Instance Segmentat

Junfeng Wu 298 Dec 22, 2022
Picasso: A CUDA-based Library for Deep Learning over 3D Meshes

The Picasso Library is intended for complex real-world applications with large-scale surfaces, while it also performs impressively on the small-scale applications over synthetic shape manifolds. We h

97 Dec 01, 2022
Code for the paper "Jukebox: A Generative Model for Music"

Status: Archive (code is provided as-is, no updates expected) Jukebox Code for "Jukebox: A Generative Model for Music" Paper Blog Explorer Colab Insta

OpenAI 6k Jan 02, 2023
ONNX-GLPDepth - Python scripts for performing monocular depth estimation using the GLPDepth model in ONNX

ONNX-GLPDepth - Python scripts for performing monocular depth estimation using the GLPDepth model in ONNX

Ibai Gorordo 18 Nov 06, 2022
A machine learning package for streaming data in Python. The other ancestor of River.

scikit-multiflow is a machine learning package for streaming data in Python. creme and scikit-multiflow are merging into a new project called River. W

670 Dec 30, 2022
DCGAN-tensorflow - A tensorflow implementation of Deep Convolutional Generative Adversarial Networks

DCGAN in Tensorflow Tensorflow implementation of Deep Convolutional Generative Adversarial Networks which is a stabilize Generative Adversarial Networ

Taehoon Kim 7.1k Dec 29, 2022
Official implementation for paper: A Latent Transformer for Disentangled Face Editing in Images and Videos.

A Latent Transformer for Disentangled Face Editing in Images and Videos Official implementation for paper: A Latent Transformer for Disentangled Face

InterDigital 108 Dec 09, 2022
2 Jul 19, 2022
An open-source, low-cost, image-based weed detection device for fallow scenarios.

Welcome to the OpenWeedLocator (OWL) project, an opensource hardware and software green-on-brown weed detector that uses entirely off-the-shelf compon

Guy Coleman 145 Jan 05, 2023
Paddle-Adversarial-Toolbox (PAT) is a Python library for Deep Learning Security based on PaddlePaddle.

Paddle-Adversarial-Toolbox Paddle-Adversarial-Toolbox (PAT) is a Python library for Deep Learning Security based on PaddlePaddle. Model Zoo Common FGS

AgentMaker 17 Nov 08, 2022
PyMove is a Python library to simplify queries and visualization of trajectories and other spatial-temporal data

Use PyMove and go much further Information Package Status License Python Version Platforms Build Status PyPi version PyPi Downloads Conda version Cond

Insight Data Science Lab 64 Nov 15, 2022
A fast poisson image editing implementation that can utilize multi-core CPU or GPU to handle a high-resolution image input.

Poisson Image Editing - A Parallel Implementation Jiayi Weng (jiayiwen), Zixu Chen (zixuc) Poisson Image Editing is a technique that can fuse two imag

Jiayi Weng 110 Dec 27, 2022