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
We present a regularized self-labeling approach to improve the generalization and robustness properties of fine-tuning.

Overview This repository provides the implementation for the paper "Improved Regularization and Robustness for Fine-tuning in Neural Networks", which

NEU-StatsML-Research 21 Sep 08, 2022
Automatic learning-rate scheduler

AutoLRS This is the PyTorch code implementation for the paper AutoLRS: Automatic Learning-Rate Schedule by Bayesian Optimization on the Fly published

Yuchen Jin 33 Nov 18, 2022
PhysCap: Physically Plausible Monocular 3D Motion Capture in Real Time

PhysCap: Physically Plausible Monocular 3D Motion Capture in Real Time The implementation is based on SIGGRAPH Aisa'20. Dependencies Python 3.7 Ubuntu

soratobtai 124 Dec 08, 2022
Reinforcement Learning for the Blackjack

Reinforcement Learning for Blackjack Author: ZHA Mengyue Math Department of HKUST Problem Statement We study playing Blackjack by reinforcement learni

Dolores 3 Jan 24, 2022
Annotate with anyone, anywhere.

h h is the web app that serves most of the https://hypothes.is/ website, including the web annotations API at https://hypothes.is/api/. The Hypothesis

Hypothesis 2.6k Jan 08, 2023
PyTorch 1.5 implementation for paper DECOR-GAN: 3D Shape Detailization by Conditional Refinement.

DECOR-GAN PyTorch 1.5 implementation for paper DECOR-GAN: 3D Shape Detailization by Conditional Refinement, Zhiqin Chen, Vladimir G. Kim, Matthew Fish

Zhiqin Chen 72 Dec 31, 2022
High frequency AI based algorithmic trading module.

Flow Flow is a high frequency algorithmic trading module that uses machine learning to self regulate and self optimize for maximum return. The current

59 Dec 14, 2022
Machine Learning with JAX Tutorials

The purpose of this repo is to make it easy to get started with JAX. It contains my "Machine Learning with JAX" series of tutorials (YouTube videos and Jupyter Notebooks) as well as the content I fou

Aleksa Gordić 372 Dec 28, 2022
The official repository for BaMBNet

BaMBNet-Pytorch Paper

Junjun Jiang 18 Dec 04, 2022
Much faster than SORT(Simple Online and Realtime Tracking), a little worse than SORT

QSORT QSORT(Quick + Simple Online and Realtime Tracking) is a simple online and realtime tracking algorithm for 2D multiple object tracking in video s

Yonghye Kwon 8 Jul 27, 2022
Repository for the paper titled: "When is BERT Multilingual? Isolating Crucial Ingredients for Cross-lingual Transfer"

When is BERT Multilingual? Isolating Crucial Ingredients for Cross-lingual Transfer This repository contains code for our paper titled "When is BERT M

Princeton Natural Language Processing 9 Dec 23, 2022
Kohei's 5th place solution for xview3 challenge

xview3-kohei-solution Usage This repository assumes that the given data set is stored in the following locations: $ ls data/input/xview3/*.csv data/in

Kohei Ozaki 2 Jan 17, 2022
MT-GAN-PyTorch - PyTorch Implementation of Learning to Transfer: Unsupervised Domain Translation via Meta-Learning

MT-GAN-PyTorch PyTorch Implementation of AAAI-2020 Paper "Learning to Transfer: Unsupervised Domain Translation via Meta-Learning" Dependency: Python

29 Oct 19, 2022
Steer OpenAI's Jukebox with Music Taggers

TagBox Steer OpenAI's Jukebox with Music Taggers! The closest thing we have to VQGAN+CLIP for music! Unsupervised Source Separation By Steering Pretra

Ethan Manilow 34 Nov 02, 2022
An image classification app boilerplate to serve your deep learning models asap!

Image 🖼 Classification App Boilerplate Have you been puzzled by tons of videos, blogs and other resources on the internet and don't know where and ho

Smaranjit Ghose 27 Oct 06, 2022
Interactive web apps created using geemap and streamlit

geemap-apps Introduction This repo demostrates how to build a multi-page Earth Engine App using streamlit and geemap. You can deploy the app on variou

Qiusheng Wu 27 Dec 23, 2022
A Transformer-Based Siamese Network for Change Detection

ChangeFormer: A Transformer-Based Siamese Network for Change Detection (Under review at IGARSS-2022) Wele Gedara Chaminda Bandara, Vishal M. Patel Her

Wele Gedara Chaminda Bandara 214 Dec 29, 2022
Just Randoms Cats with python

Random-Cat Just Randoms Cats with python.

OriCode 2 Dec 21, 2021
PyTorch code for ICLR 2021 paper Unbiased Teacher for Semi-Supervised Object Detection

Unbiased Teacher for Semi-Supervised Object Detection This is the PyTorch implementation of our paper: Unbiased Teacher for Semi-Supervised Object Detection

Facebook Research 366 Dec 28, 2022
[2021][ICCV][FSNet] Full-Duplex Strategy for Video Object Segmentation

Full-Duplex Strategy for Video Object Segmentation (ICCV, 2021) Authors: Ge-Peng Ji, Keren Fu, Zhe Wu, Deng-Ping Fan*, Jianbing Shen, & Ling Shao This

Daniel-Ji 55 Dec 22, 2022