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
A small demonstration of using WebDataset with ImageNet and PyTorch Lightning

A small demonstration of using WebDataset with ImageNet and PyTorch Lightning This is a small repo illustrating how to use WebDataset on ImageNet. usi

50 Dec 16, 2022
Training, generation, and analysis code for Learning Particle Physics by Example: Location-Aware Generative Adversarial Networks for Physics

Location-Aware Generative Adversarial Networks (LAGAN) for Physics Synthesis This repository contains all the code used in L. de Oliveira (@lukedeo),

Deep Learning for HEP 57 Oct 22, 2022
A Gura parser implementation for Python

Gura Python parser This repository contains the implementation of a Gura (compliant with version 1.0.0) format parser in Python. Installation pip inst

Gura Config Lang 19 Jan 25, 2022
An example of semantic segmentation using tensorflow in eager execution.

Semantic segmentation using Tensorflow eager execution Requirement Python 2.7+ Tensorflow-gpu OpenCv H5py Scikit-learn Numpy Imgaug Train with eager e

Iñigo Alonso Ruiz 25 Sep 29, 2022
JUSTICE: A Benchmark Dataset for Supreme Court’s Judgment Prediction

JUSTICE: A Benchmark Dataset for Supreme Court’s Judgment Prediction CSCI 544 Final Project done by: Mohammed Alsayed, Shaayan Syed, Mohammad Alali, S

Smit Patel 3 Dec 28, 2022
Official PyTorch implementation of "ArtFlow: Unbiased Image Style Transfer via Reversible Neural Flows"

ArtFlow Official PyTorch implementation of the paper: ArtFlow: Unbiased Image Style Transfer via Reversible Neural Flows Jie An*, Siyu Huang*, Yibing

123 Dec 27, 2022
DynaTune: Dynamic Tensor Program Optimization in Deep Neural Network Compilation

DynaTune: Dynamic Tensor Program Optimization in Deep Neural Network Compilation This repository is the implementation of DynaTune paper. This folder

4 Nov 02, 2022
GNEE - GAT Neural Event Embeddings

GNEE - GAT Neural Event Embeddings This repository contains source code for the GNEE (GAT Neural Event Embeddings) method introduced in the paper: "Se

João Pedro Rodrigues Mattos 0 Sep 15, 2021
Python PID Tuner - Makes a model of the System from a Process Reaction Curve and calculates PID Gains

PythonPID_Tuner_SOPDT Step 1: Takes a Process Reaction Curve in csv format - assumes data at 100ms interval (column names CV and PV) Step 2: Makes a r

1 Jan 18, 2022
Contains source code for the winning solution of the xView3 challenge

Winning Solution for xView3 Challenge This repository contains source code and pretrained models for my (Eugene Khvedchenya) solution to xView 3 Chall

Eugene Khvedchenya 51 Dec 30, 2022
Code for "Share With Thy Neighbors: Single-View Reconstruction by Cross-Instance Consistency" paper

UNICORN 🦄 Webpage | Paper | BibTex PyTorch implementation of "Share With Thy Neighbors: Single-View Reconstruction by Cross-Instance Consistency" pap

118 Jan 06, 2023
Predicting Axillary Lymph Node Metastasis in Early Breast Cancer Using Deep Learning on Primary Tumor Biopsy Slides

Predicting Axillary Lymph Node Metastasis in Early Breast Cancer Using Deep Learning on Primary Tumor Biopsy Slides Project | This repo is the officia

CVSM Group - email: <a href=[email protected]"> 33 Dec 28, 2022
"Learning and Analyzing Generation Order for Undirected Sequence Models" in Findings of EMNLP, 2021

undirected-generation-dev This repo contains the source code of the models described in the following paper "Learning and Analyzing Generation Order f

Yichen Jiang 0 Mar 25, 2022
Advanced yabai wooting scripts

Yabai Wooting scripts Installation requirements Both https://github.com/xiamaz/python-yabai-client and https://github.com/xiamaz/python-wooting-rgb ne

Max Zhao 3 Dec 31, 2021
Code repository for "Free View Synthesis", ECCV 2020.

Free View Synthesis Code repository for "Free View Synthesis", ECCV 2020. Setup Install the following Python packages in your Python environment - num

Intelligent Systems Lab Org 253 Dec 07, 2022
Code for paper: "Spinning Language Models for Propaganda-As-A-Service"

Spinning Language Models for Propaganda-As-A-Service This is the source code for the Arxiv version of the paper. You can use this Google Colab to expl

Eugene Bagdasaryan 16 Jan 03, 2023
Pytorch implementation of the paper Progressive Growing of Points with Tree-structured Generators (BMVC 2021)

PGpoints Pytorch implementation of the paper Progressive Growing of Points with Tree-structured Generators (BMVC 2021) Hyeontae Son, Young Min Kim Pre

Hyeontae Son 9 Jun 06, 2022
The official homepage of the COCO-Stuff dataset.

The COCO-Stuff dataset Holger Caesar, Jasper Uijlings, Vittorio Ferrari Welcome to official homepage of the COCO-Stuff [1] dataset. COCO-Stuff augment

Holger Caesar 715 Dec 31, 2022
Learning recognition/segmentation models without end-to-end training. 40%-60% less GPU memory footprint. Same training time. Better performance.

InfoPro-Pytorch The Information Propagation algorithm for training deep networks with local supervision. (ICLR 2021) Revisiting Locally Supervised Lea

78 Dec 27, 2022
Official repo for QHack—the quantum machine learning hackathon

Note: This repository has been frozen while we consider the submissions for the QHack Open Hackathon. We hope you enjoyed the event! Welcome to QHack,

Xanadu 118 Jan 05, 2023