├── .gitignore ├── .pre-commit-config.yaml ├── LICENSE ├── README.md ├── app.py ├── data ├── .DS_Store ├── example_images │ ├── .DS_Store │ ├── .gitignore │ ├── example_1.jpg │ ├── example_10.jpg │ ├── example_11.jpg │ ├── example_12.jpg │ ├── example_13.jpg │ ├── example_14.jpg │ ├── example_15.jpg │ ├── example_16.jpg │ ├── example_17.jpg │ ├── example_18.jpg │ ├── example_19.jpg │ ├── example_2.jpg │ ├── example_20.jpg │ ├── example_21.jpg │ ├── example_22.jpg │ ├── example_23.jpg │ ├── example_24.jpg │ ├── example_25.jpg │ ├── example_26.jpg │ ├── example_27.jpg │ ├── example_28.jpg │ ├── example_29.jpg │ ├── example_3.jpg │ ├── example_30.jpg │ ├── example_31.jpg │ ├── example_32.jpg │ ├── example_33.jpg │ ├── example_34.jpg │ ├── example_35.jpg │ ├── example_36.jpg │ ├── example_37.jpg │ ├── example_38.jpg │ ├── example_39.jpg │ ├── example_4.jpg │ ├── example_5.jpg │ ├── example_6.jpg │ ├── example_7.jpg │ ├── example_8.jpg │ └── example_9.jpg ├── example_videos │ ├── .DS_Store │ └── .gitignore ├── images │ ├── 1027_png.rf.cda5c3b663ae9d3ffd8c0afdbfb5e9fc.jpg │ ├── 1028_png.rf.48105563f26c08b67a99b97e7e24f1b7.jpg │ ├── 1034_png.rf.cb292edb5d8b1b5032e9ba9a64b7baba.jpg │ ├── 1040_png.rf.7875a970c719749040a05d8fe410ebd5.jpg │ ├── 1043_png.rf.5ac5bfc8ac2ccb6c5dc31e680082d9d8.jpg │ ├── 1045_png.rf.81fe59a6daa1bcdef884d0666bef90bd.jpg │ ├── 1048_png.rf.60547dc42f8cff52ec20d1bcb37d53f0.jpg │ ├── 1052_png.rf.4a2029e91db18ca25f679d822f648ac2.jpg │ ├── 1054_png.rf.1c9111ccc45c77cbe2ec08a880f7d85c.jpg │ ├── 1055_png.rf.5984cfe13a8ab2e1e84c7f3d508602f2.jpg │ ├── 1058_png.rf.e6d90ea53f0f53acda8ff8d43022ad41.jpg │ ├── 1065_png.rf.dddcc4695494a09e16b83ef24d7cb590.jpg │ ├── 1069_png.rf.14b7287e085e63d88513be59d18b6af1.jpg │ ├── 1071_png.rf.66695a927d59047a028460c76412484a.jpg │ ├── 1079_png.rf.c4aba5f9965b9db1853c761d9315f97e.jpg │ ├── 1112_png.rf.e29303b7a65020c5f521569522ae4b0f.jpg │ ├── 1176_png.rf.edac8a7c96a2c6b7557e088bb90bb8d1.jpg │ ├── 1186_png.rf.2dbb10e723b58700b24e0dc9637eb0fb.jpg │ ├── 1187_png.rf.9c727c8b4484c524dac7a5319174efa1.jpg │ ├── 118_png.rf.ea1cddba411bc5c8da0a5ed54388fce1.jpg │ ├── 1195_png.rf.5837e356d19a6a7aadfcf400cb085378.jpg │ ├── 1209_png.rf.b4e451e923e86c89a87209fdfd6b2241.jpg │ ├── 1217_png.rf.ec25ff10a6789d4ee084bb02dc4d7f8b.jpg │ ├── 1239_png.rf.908939f461a5c7d780ecd428c61b7ca5.jpg │ ├── 1245_png.rf.576c46daa0837565b78089e7d6ce5d71.jpg │ ├── 124_png.rf.40f04e8d386b4539d2f1ffee1e1f89fa.jpg │ ├── 1251_png.rf.2af43f0fe1ca2e2f3dac90bdee5876d0.jpg │ ├── 1253_png.rf.dfaf5beae6f28b8ab25cac8ca4626afc.jpg │ ├── 1269_png.rf.542f482ae7b6ce89416dabf9d53c290c.jpg │ ├── 126_png.rf.3e5644bbcdce8bfcd57a8b25f258d5db.jpg │ ├── 127_png.rf.79576d96ac85d2eed2e4508e10596aac.jpg │ ├── 1280_png.rf.fdd6f25e9003fd756eb20a645e59fd0a.jpg │ ├── 1302_png.rf.dfc194d802573aea9246cc4e8eed5dfa.jpg │ ├── 133_png.rf.ae653945db0085ad8f340d62ef7e9f34.jpg │ ├── 888_png.rf.209110ac16fb6f523aa136b16e92f92d.jpg │ ├── 908_png.rf.1c8aed116f4fa92085a172cd9dc0e072.jpg │ ├── 921_png.rf.a7c01f333a6cfd51129a2c75016ae896.jpg │ ├── 923_png.rf.2cd952d8016f9b0ec3d69ed4f215d347.jpg │ └── 925_png.rf.24c2ed106b6a36c8ddd9e256f327424b.jpg ├── outputs │ ├── .DS_Store │ └── .gitignore ├── uploads │ ├── .DS_Store │ └── .gitignore ├── video_frames │ ├── .DS_Store │ └── .gitignore └── video_output │ ├── .DS_Store │ └── .gitignore ├── models └── .gitignore ├── packages.txt ├── requirements.txt └── video_predict.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Repo-specific GitIgnore ---------------------------------------------------------------------------------------------- 2 | *.jpg 3 | *.jpeg 4 | *.png 5 | *.bmp 6 | *.tif 7 | *.tiff 8 | *.heic 9 | *.JPG 10 | *.JPEG 11 | *.PNG 12 | *.BMP 13 | *.TIF 14 | *.TIFF 15 | *.HEIC 16 | *.mp4 17 | *.mov 18 | *.MOV 19 | *.avi 20 | *.data 21 | *.json 22 | *.cfg 23 | !setup.cfg 24 | !cfg/yolov3*.cfg 25 | 26 | storage.googleapis.com 27 | runs/* 28 | 29 | 30 | !data/*.yaml 31 | !data/hyps 32 | !data/scripts 33 | 34 | !data/*.sh 35 | 36 | results*.csv 37 | 38 | # Datasets ------------------------------------------------------------------------------------------------------------- 39 | coco/ 40 | coco128/ 41 | VOC/ 42 | 43 | # MATLAB GitIgnore ----------------------------------------------------------------------------------------------------- 44 | *.m~ 45 | *.mat 46 | !targets*.mat 47 | 48 | # Neural Network weights ----------------------------------------------------------------------------------------------- 49 | *.weights 50 | *.pt 51 | *.pb 52 | *.onnx 53 | *.engine 54 | *.mlmodel 55 | *.torchscript 56 | *.tflite 57 | *.h5 58 | *_saved_model/ 59 | *_web_model/ 60 | *_openvino_model/ 61 | darknet53.conv.74 62 | yolov3-tiny.conv.15 63 | 64 | # GitHub Python GitIgnore ---------------------------------------------------------------------------------------------- 65 | # Byte-compiled / optimized / DLL files 66 | __pycache__/ 67 | *.py[cod] 68 | *$py.class 69 | 70 | # C extensions 71 | *.so 72 | 73 | # Distribution / packaging 74 | .Python 75 | env/ 76 | build/ 77 | develop-eggs/ 78 | dist/ 79 | downloads/ 80 | eggs/ 81 | .eggs/ 82 | lib/ 83 | lib64/ 84 | parts/ 85 | sdist/ 86 | var/ 87 | wheels/ 88 | *.egg-info/ 89 | /wandb/ 90 | .installed.cfg 91 | *.egg 92 | 93 | 94 | # PyInstaller 95 | # Usually these files are written by a python script from a template 96 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 97 | *.manifest 98 | *.spec 99 | 100 | # Installer logs 101 | pip-log.txt 102 | pip-delete-this-directory.txt 103 | 104 | # Unit test / coverage reports 105 | htmlcov/ 106 | .tox/ 107 | .coverage 108 | .coverage.* 109 | .cache 110 | nosetests.xml 111 | coverage.xml 112 | *.cover 113 | .hypothesis/ 114 | 115 | # Translations 116 | *.mo 117 | *.pot 118 | 119 | # Django stuff: 120 | *.log 121 | local_settings.py 122 | 123 | # Flask stuff: 124 | instance/ 125 | .webassets-cache 126 | 127 | # Scrapy stuff: 128 | .scrapy 129 | 130 | # Sphinx documentation 131 | docs/_build/ 132 | 133 | # PyBuilder 134 | target/ 135 | 136 | # Jupyter Notebook 137 | .ipynb_checkpoints 138 | 139 | # pyenv 140 | .python-version 141 | 142 | # celery beat schedule file 143 | celerybeat-schedule 144 | 145 | # SageMath parsed files 146 | *.sage.py 147 | 148 | # dotenv 149 | .env 150 | 151 | # virtualenv 152 | .venv* 153 | venv*/ 154 | ENV*/ 155 | 156 | # Spyder project settings 157 | .spyderproject 158 | .spyproject 159 | 160 | # Rope project settings 161 | .ropeproject 162 | 163 | # mkdocs documentation 164 | /site 165 | 166 | # mypy 167 | .mypy_cache/ 168 | 169 | 170 | # https://github.com/github/gitignore/blob/master/Global/macOS.gitignore ----------------------------------------------- 171 | 172 | # General 173 | */.DS_Store 174 | .DS_Store 175 | .AppleDouble 176 | .LSOverride 177 | 178 | # Icon must end with two \r 179 | Icon 180 | Icon? 181 | 182 | # Thumbnails 183 | ._* 184 | 185 | # Files that might appear in the root of a volume 186 | .DocumentRevisions-V100 187 | .fseventsd 188 | .Spotlight-V100 189 | .TemporaryItems 190 | .Trashes 191 | .VolumeIcon.icns 192 | .com.apple.timemachine.donotpresent 193 | 194 | # Directories potentially created on remote AFP share 195 | .AppleDB 196 | .AppleDesktop 197 | Network Trash Folder 198 | Temporary Items 199 | .apdisk 200 | 201 | 202 | # https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore 203 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 204 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 205 | 206 | # User-specific stuff: 207 | .idea/* 208 | .idea/**/workspace.xml 209 | .idea/**/tasks.xml 210 | .idea/dictionaries 211 | .html # Bokeh Plots 212 | .pg # TensorFlow Frozen Graphs 213 | .avi # videos 214 | 215 | # Sensitive or high-churn files: 216 | .idea/**/dataSources/ 217 | .idea/**/dataSources.ids 218 | .idea/**/dataSources.local.xml 219 | .idea/**/sqlDataSources.xml 220 | .idea/**/dynamic.xml 221 | .idea/**/uiDesigner.xml 222 | 223 | # Gradle: 224 | .idea/**/gradle.xml 225 | .idea/**/libraries 226 | 227 | # CMake 228 | cmake-build-debug/ 229 | cmake-build-release/ 230 | 231 | # Mongo Explorer plugin: 232 | .idea/**/mongoSettings.xml 233 | 234 | ## File-based project format: 235 | *.iws 236 | 237 | ## Plugin-specific files: 238 | 239 | # IntelliJ 240 | out/ 241 | 242 | # mpeltonen/sbt-idea plugin 243 | .idea_modules/ 244 | 245 | # JIRA plugin 246 | atlassian-ide-plugin.xml 247 | 248 | # Cursive Clojure plugin 249 | .idea/replstate.xml 250 | 251 | # Crashlytics plugin (for Android Studio and IntelliJ) 252 | com_crashlytics_export_strings.xml 253 | crashlytics.properties 254 | crashlytics-build.properties 255 | fabric.properties 256 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # Define hooks for code formations 2 | # Will be applied on any updated commit files if a user has installed and linked commit hook 3 | 4 | default_language_version: 5 | python: python3.8 6 | 7 | # Define bot property if installed via https://github.com/marketplace/pre-commit-ci 8 | ci: 9 | autofix_prs: true 10 | autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions' 11 | autoupdate_schedule: monthly 12 | # submodules: true 13 | 14 | repos: 15 | - repo: https://github.com/pre-commit/pre-commit-hooks 16 | rev: v4.2.0 17 | hooks: 18 | - id: end-of-file-fixer 19 | - id: trailing-whitespace 20 | - id: check-case-conflict 21 | - id: check-yaml 22 | - id: check-toml 23 | - id: pretty-format-json 24 | - id: check-docstring-first 25 | 26 | - repo: https://github.com/asottile/pyupgrade 27 | rev: v2.32.1 28 | hooks: 29 | - id: pyupgrade 30 | name: Upgrade code 31 | args: [ --py37-plus ] 32 | 33 | - repo: https://github.com/PyCQA/isort 34 | rev: 5.10.1 35 | hooks: 36 | - id: isort 37 | name: Sort imports 38 | 39 | - repo: https://github.com/pre-commit/mirrors-yapf 40 | rev: v0.32.0 41 | hooks: 42 | - id: yapf 43 | name: YAPF formatting 44 | 45 | - repo: https://github.com/executablebooks/mdformat 46 | rev: 0.7.14 47 | hooks: 48 | - id: mdformat 49 | name: MD formatting 50 | additional_dependencies: 51 | - mdformat-gfm 52 | - mdformat-black 53 | exclude: | 54 | (?x)^( 55 | README.md 56 | )$ 57 | 58 | - repo: https://github.com/asottile/yesqa 59 | rev: v1.3.0 60 | hooks: 61 | - id: yesqa 62 | 63 | - repo: https://github.com/PyCQA/flake8 64 | rev: 4.0.1 65 | hooks: 66 | - id: flake8 67 | name: PEP8 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Thepbordin Jaiinsom 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # 🚀 YOLOv5 Streamlit Deployment 3 | [![HitCount](https://hits.dwyl.com/thepbordin/YOLOv5-Streamlit-Deployment.svg?style=flat&show=unique)](http://hits.dwyl.com/thepbordin/YOLOv5-Streamlit-Deployment) 4 | 5 | 6 | A Easy way to deploy [YOLOv5](https://github.com/ultralytics/yolov5) object detection model with [Streamlit](https://streamlit.io/). 7 | 8 | **Please feel free to use/edit.** 9 | 10 | 11 | code modified by GitHub/thepbordin from GitHub/zhoroh 12 | 13 | ## ✨ Features 14 | 15 | - YOLO Weights Source 16 | - Load from Local 17 | - Download Weights from URL 18 | - Example Dataset 19 | - Videos 20 | - Images 21 | - Upload Data 22 | - Video 23 | - Image 24 | - Select computing device (cuda/cpu) 25 | 26 | 27 | 28 | ## ⚙️ Installation 29 | 30 | 31 | 32 | ### Local Use 33 | 1. Install Requirements 34 | `pip install -r requirements.txt` 35 | 2. Install ffmpeg (for video inferencing) 36 | - For Windows [read here](https://www.geeksforgeeks.org/how-to-install-ffmpeg-on-windows/) 37 | - For Mac (brew) 38 | `brew install ffmpeg` 39 | 3. Strart Stremlit 40 | ``` 41 | cd YOLOv5-Streamlit-Deployment 42 | streamlit run app.py 43 | ``` 44 | ### Streamlit Cloud 45 | 1. Edit a configuration in app.py (read ⚙️ Config Instruction) 46 | 2. (Optional) Upload example datas in 47 | - `example_images` 48 | - `example_videos` 49 | 4. Deploy on [Streamlit](https://share.streamlit.io/deploy) 50 | 51 | 52 | ## ⚙️ Config Instruction 53 | ### Download model from URL 54 | 55 | 1. Upload model to [Internet Archive](https://archive.org/) 56 | 2. Go to your uploaded file page. 57 | 3. From `DOWNLOAD OPTIONS` select `SHOW ALL` 58 | 4. Right click at .pt and Copy link address. 59 | 5. Edit config in [app.py](https://github.com/thepbordin/YOLOv5-Streamlit-Deployment/blob/main/app.py) 60 | 61 | ```python 62 | cfg_enable_url_download = True 63 | url = "your_model_url" 64 | ``` 65 | 66 | ### Use local .pt file: 67 | Edit config in [app.py](https://github.com/thepbordin/YOLOv5-Streamlit-Deployment/blob/main/app.py) 68 | ```python 69 | ## CFG 70 | cfg_model_path = "models/your_model_name.pt" 71 | ``` 72 | 73 | ## Reference 74 | [Yolov5 Real-time Inference using Streamlit](https://github.com/moaaztaha/Yolo-Interface-using-Streamlit) 75 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | import torch 3 | from PIL import Image 4 | from io import * 5 | import glob 6 | from datetime import datetime 7 | import os 8 | import wget 9 | from video_predict import runVideo 10 | 11 | 12 | # Configurations 13 | CFG_MODEL_PATH = "models/yourModel.pt" 14 | CFG_ENABLE_URL_DOWNLOAD = True 15 | CFG_ENABLE_VIDEO_PREDICTION = True 16 | if CFG_ENABLE_URL_DOWNLOAD: 17 | # Configure this if you set cfg_enable_url_download to True 18 | url = "https://archive.org/download/yoloTrained/yoloTrained.pt" 19 | # End of Configurations 20 | 21 | 22 | def imageInput(model, src): 23 | 24 | if src == 'Upload your own data.': 25 | image_file = st.file_uploader( 26 | "Upload An Image", type=['png', 'jpeg', 'jpg']) 27 | col1, col2 = st.columns(2) 28 | if image_file is not None: 29 | img = Image.open(image_file) 30 | with col1: 31 | st.image(img, caption='Uploaded Image', 32 | use_column_width='always') 33 | ts = datetime.timestamp(datetime.now()) 34 | imgpath = os.path.join('data/uploads', str(ts)+image_file.name) 35 | outputpath = os.path.join( 36 | 'data/outputs', os.path.basename(imgpath)) 37 | with open(imgpath, mode="wb") as f: 38 | f.write(image_file.getbuffer()) 39 | 40 | with st.spinner(text="Predicting..."): 41 | # Load model 42 | pred = model(imgpath) 43 | pred.render() 44 | # save output to file 45 | for im in pred.ims: 46 | im_base64 = Image.fromarray(im) 47 | im_base64.save(outputpath) 48 | 49 | # Predictions 50 | img_ = Image.open(outputpath) 51 | with col2: 52 | st.image(img_, caption='Model Prediction(s)', 53 | use_column_width='always') 54 | 55 | elif src == 'From example data.': 56 | # Image selector slider 57 | imgpaths = glob.glob('data/example_images/*') 58 | if len(imgpaths) == 0: 59 | st.write(".") 60 | st.error( 61 | 'No images found, Please upload example images in data/example_images', icon="") 62 | return 63 | imgsel = st.slider('Select random images from example data.', 64 | min_value=1, max_value=len(imgpaths), step=1) 65 | image_file = imgpaths[imgsel-1] 66 | submit = st.button("Predict!") 67 | col1, col2 = st.columns(2) 68 | with col1: 69 | img = Image.open(image_file) 70 | st.image(img, caption='Selected Image', use_column_width='always') 71 | with col2: 72 | if image_file is not None and submit: 73 | with st.spinner(text="Predicting..."): 74 | # Load model 75 | 76 | pred = model(image_file) 77 | pred.render() 78 | # save output to file 79 | for im in pred.ims: 80 | im_base64 = Image.fromarray(im) 81 | im_base64.save(os.path.join( 82 | 'data/outputs', os.path.basename(image_file))) 83 | # Display predicton 84 | img_ = Image.open(os.path.join( 85 | 'data/outputs', os.path.basename(image_file))) 86 | st.image(img_, caption='Model Prediction(s)') 87 | 88 | 89 | def videoInput(model, src): 90 | if src == 'Upload your own data.': 91 | uploaded_video = st.file_uploader( 92 | "Upload A Video", type=['mp4', 'mpeg', 'mov']) 93 | pred_view = st.empty() 94 | warning = st.empty() 95 | if uploaded_video != None: 96 | 97 | # Save video to disk 98 | ts = datetime.timestamp(datetime.now()) # timestamp a upload 99 | uploaded_video_path = os.path.join( 100 | 'data/uploads', str(ts)+uploaded_video.name) 101 | with open(uploaded_video_path, mode='wb') as f: 102 | f.write(uploaded_video.read()) 103 | 104 | # Display uploaded video 105 | with open(uploaded_video_path, 'rb') as f: 106 | video_bytes = f.read() 107 | st.video(video_bytes) 108 | st.write("Uploaded Video") 109 | submit = st.button("Run Prediction") 110 | if submit: 111 | runVideo(model, uploaded_video_path, pred_view, warning) 112 | 113 | elif src == 'From example data.': 114 | # Image selector slider 115 | videopaths = glob.glob('data/example_videos/*') 116 | if len(videopaths) == 0: 117 | st.error( 118 | 'No videos found, Please upload example videos in data/example_videos', icon="⚠️") 119 | return 120 | imgsel = st.slider('Select random video from example data.', 121 | min_value=1, max_value=len(videopaths), step=1) 122 | pred_view = st.empty() 123 | video = videopaths[imgsel-1] 124 | submit = st.button("Predict!") 125 | if submit: 126 | runVideo(model, video, pred_view, warning) 127 | 128 | 129 | def main(): 130 | if CFG_ENABLE_URL_DOWNLOAD: 131 | downloadModel() 132 | 133 | else: 134 | if not os.path.exists(CFG_MODEL_PATH): 135 | st.error( 136 | 'Model not found, please config if you wish to download model from url set `cfg_enable_url_download = True` ', icon="⚠️") 137 | 138 | # -- Sidebar 139 | st.sidebar.title('⚙️ Options') 140 | datasrc = st.sidebar.radio("Select input source.", [ 141 | 'From example data.', 'Upload your own data.']) 142 | 143 | if CFG_ENABLE_VIDEO_PREDICTION: 144 | option = st.sidebar.radio("Select input type.", ['Image', 'Video']) 145 | else: 146 | option = st.sidebar.radio("Select input type.", ['Image']) 147 | if torch.cuda.is_available(): 148 | deviceoption = st.sidebar.radio("Select compute Device.", [ 149 | 'cpu', 'cuda'], disabled=False, index=1) 150 | else: 151 | deviceoption = st.sidebar.radio("Select compute Device.", [ 152 | 'cpu', 'cuda'], disabled=True, index=0) 153 | # -- End of Sidebar 154 | 155 | st.header('📦 YOLOv5 Streamlit Deployment Example') 156 | st.sidebar.markdown( 157 | "https://github.com/thepbordin/Obstacle-Detection-for-Blind-people-Deployment") 158 | 159 | if option == "Image": 160 | imageInput(loadmodel(deviceoption), datasrc) 161 | elif option == "Video": 162 | videoInput(loadmodel(deviceoption), datasrc) 163 | 164 | 165 | # Downlaod Model from url. 166 | @st.cache_resource 167 | def downloadModel(): 168 | if not os.path.exists(CFG_MODEL_PATH): 169 | wget.download(url, out="models/") 170 | 171 | 172 | @st.cache_resource 173 | def loadmodel(device): 174 | if CFG_ENABLE_URL_DOWNLOAD: 175 | CFG_MODEL_PATH = f"models/{url.split('/')[-1:][0]}" 176 | model = torch.hub.load('ultralytics/yolov5', 'custom', 177 | path=CFG_MODEL_PATH, force_reload=True, device=device) 178 | return model 179 | 180 | 181 | if __name__ == '__main__': 182 | main() 183 | -------------------------------------------------------------------------------- /data/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/.DS_Store -------------------------------------------------------------------------------- /data/example_images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/.DS_Store -------------------------------------------------------------------------------- /data/example_images/.gitignore: -------------------------------------------------------------------------------- 1 | !* -------------------------------------------------------------------------------- /data/example_images/example_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_1.jpg -------------------------------------------------------------------------------- /data/example_images/example_10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_10.jpg -------------------------------------------------------------------------------- /data/example_images/example_11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_11.jpg -------------------------------------------------------------------------------- /data/example_images/example_12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_12.jpg -------------------------------------------------------------------------------- /data/example_images/example_13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_13.jpg -------------------------------------------------------------------------------- /data/example_images/example_14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_14.jpg -------------------------------------------------------------------------------- /data/example_images/example_15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_15.jpg -------------------------------------------------------------------------------- /data/example_images/example_16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_16.jpg -------------------------------------------------------------------------------- /data/example_images/example_17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_17.jpg -------------------------------------------------------------------------------- /data/example_images/example_18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_18.jpg -------------------------------------------------------------------------------- /data/example_images/example_19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_19.jpg -------------------------------------------------------------------------------- /data/example_images/example_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_2.jpg -------------------------------------------------------------------------------- /data/example_images/example_20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_20.jpg -------------------------------------------------------------------------------- /data/example_images/example_21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_21.jpg -------------------------------------------------------------------------------- /data/example_images/example_22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_22.jpg -------------------------------------------------------------------------------- /data/example_images/example_23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_23.jpg -------------------------------------------------------------------------------- /data/example_images/example_24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_24.jpg -------------------------------------------------------------------------------- /data/example_images/example_25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_25.jpg -------------------------------------------------------------------------------- /data/example_images/example_26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_26.jpg -------------------------------------------------------------------------------- /data/example_images/example_27.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_27.jpg -------------------------------------------------------------------------------- /data/example_images/example_28.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_28.jpg -------------------------------------------------------------------------------- /data/example_images/example_29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_29.jpg -------------------------------------------------------------------------------- /data/example_images/example_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_3.jpg -------------------------------------------------------------------------------- /data/example_images/example_30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_30.jpg -------------------------------------------------------------------------------- /data/example_images/example_31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_31.jpg -------------------------------------------------------------------------------- /data/example_images/example_32.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_32.jpg -------------------------------------------------------------------------------- /data/example_images/example_33.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_33.jpg -------------------------------------------------------------------------------- /data/example_images/example_34.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_34.jpg -------------------------------------------------------------------------------- /data/example_images/example_35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_35.jpg -------------------------------------------------------------------------------- /data/example_images/example_36.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_36.jpg -------------------------------------------------------------------------------- /data/example_images/example_37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_37.jpg -------------------------------------------------------------------------------- /data/example_images/example_38.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_38.jpg -------------------------------------------------------------------------------- /data/example_images/example_39.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_39.jpg -------------------------------------------------------------------------------- /data/example_images/example_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_4.jpg -------------------------------------------------------------------------------- /data/example_images/example_5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_5.jpg -------------------------------------------------------------------------------- /data/example_images/example_6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_6.jpg -------------------------------------------------------------------------------- /data/example_images/example_7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_7.jpg -------------------------------------------------------------------------------- /data/example_images/example_8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_8.jpg -------------------------------------------------------------------------------- /data/example_images/example_9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_images/example_9.jpg -------------------------------------------------------------------------------- /data/example_videos/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/example_videos/.DS_Store -------------------------------------------------------------------------------- /data/example_videos/.gitignore: -------------------------------------------------------------------------------- 1 | !* -------------------------------------------------------------------------------- /data/images/1027_png.rf.cda5c3b663ae9d3ffd8c0afdbfb5e9fc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1027_png.rf.cda5c3b663ae9d3ffd8c0afdbfb5e9fc.jpg -------------------------------------------------------------------------------- /data/images/1028_png.rf.48105563f26c08b67a99b97e7e24f1b7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1028_png.rf.48105563f26c08b67a99b97e7e24f1b7.jpg -------------------------------------------------------------------------------- /data/images/1034_png.rf.cb292edb5d8b1b5032e9ba9a64b7baba.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1034_png.rf.cb292edb5d8b1b5032e9ba9a64b7baba.jpg -------------------------------------------------------------------------------- /data/images/1040_png.rf.7875a970c719749040a05d8fe410ebd5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1040_png.rf.7875a970c719749040a05d8fe410ebd5.jpg -------------------------------------------------------------------------------- /data/images/1043_png.rf.5ac5bfc8ac2ccb6c5dc31e680082d9d8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1043_png.rf.5ac5bfc8ac2ccb6c5dc31e680082d9d8.jpg -------------------------------------------------------------------------------- /data/images/1045_png.rf.81fe59a6daa1bcdef884d0666bef90bd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1045_png.rf.81fe59a6daa1bcdef884d0666bef90bd.jpg -------------------------------------------------------------------------------- /data/images/1048_png.rf.60547dc42f8cff52ec20d1bcb37d53f0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1048_png.rf.60547dc42f8cff52ec20d1bcb37d53f0.jpg -------------------------------------------------------------------------------- /data/images/1052_png.rf.4a2029e91db18ca25f679d822f648ac2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1052_png.rf.4a2029e91db18ca25f679d822f648ac2.jpg -------------------------------------------------------------------------------- /data/images/1054_png.rf.1c9111ccc45c77cbe2ec08a880f7d85c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1054_png.rf.1c9111ccc45c77cbe2ec08a880f7d85c.jpg -------------------------------------------------------------------------------- /data/images/1055_png.rf.5984cfe13a8ab2e1e84c7f3d508602f2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1055_png.rf.5984cfe13a8ab2e1e84c7f3d508602f2.jpg -------------------------------------------------------------------------------- /data/images/1058_png.rf.e6d90ea53f0f53acda8ff8d43022ad41.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1058_png.rf.e6d90ea53f0f53acda8ff8d43022ad41.jpg -------------------------------------------------------------------------------- /data/images/1065_png.rf.dddcc4695494a09e16b83ef24d7cb590.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1065_png.rf.dddcc4695494a09e16b83ef24d7cb590.jpg -------------------------------------------------------------------------------- /data/images/1069_png.rf.14b7287e085e63d88513be59d18b6af1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1069_png.rf.14b7287e085e63d88513be59d18b6af1.jpg -------------------------------------------------------------------------------- /data/images/1071_png.rf.66695a927d59047a028460c76412484a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1071_png.rf.66695a927d59047a028460c76412484a.jpg -------------------------------------------------------------------------------- /data/images/1079_png.rf.c4aba5f9965b9db1853c761d9315f97e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1079_png.rf.c4aba5f9965b9db1853c761d9315f97e.jpg -------------------------------------------------------------------------------- /data/images/1112_png.rf.e29303b7a65020c5f521569522ae4b0f.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1112_png.rf.e29303b7a65020c5f521569522ae4b0f.jpg -------------------------------------------------------------------------------- /data/images/1176_png.rf.edac8a7c96a2c6b7557e088bb90bb8d1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1176_png.rf.edac8a7c96a2c6b7557e088bb90bb8d1.jpg -------------------------------------------------------------------------------- /data/images/1186_png.rf.2dbb10e723b58700b24e0dc9637eb0fb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1186_png.rf.2dbb10e723b58700b24e0dc9637eb0fb.jpg -------------------------------------------------------------------------------- /data/images/1187_png.rf.9c727c8b4484c524dac7a5319174efa1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1187_png.rf.9c727c8b4484c524dac7a5319174efa1.jpg -------------------------------------------------------------------------------- /data/images/118_png.rf.ea1cddba411bc5c8da0a5ed54388fce1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/118_png.rf.ea1cddba411bc5c8da0a5ed54388fce1.jpg -------------------------------------------------------------------------------- /data/images/1195_png.rf.5837e356d19a6a7aadfcf400cb085378.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1195_png.rf.5837e356d19a6a7aadfcf400cb085378.jpg -------------------------------------------------------------------------------- /data/images/1209_png.rf.b4e451e923e86c89a87209fdfd6b2241.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1209_png.rf.b4e451e923e86c89a87209fdfd6b2241.jpg -------------------------------------------------------------------------------- /data/images/1217_png.rf.ec25ff10a6789d4ee084bb02dc4d7f8b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1217_png.rf.ec25ff10a6789d4ee084bb02dc4d7f8b.jpg -------------------------------------------------------------------------------- /data/images/1239_png.rf.908939f461a5c7d780ecd428c61b7ca5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1239_png.rf.908939f461a5c7d780ecd428c61b7ca5.jpg -------------------------------------------------------------------------------- /data/images/1245_png.rf.576c46daa0837565b78089e7d6ce5d71.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1245_png.rf.576c46daa0837565b78089e7d6ce5d71.jpg -------------------------------------------------------------------------------- /data/images/124_png.rf.40f04e8d386b4539d2f1ffee1e1f89fa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/124_png.rf.40f04e8d386b4539d2f1ffee1e1f89fa.jpg -------------------------------------------------------------------------------- /data/images/1251_png.rf.2af43f0fe1ca2e2f3dac90bdee5876d0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1251_png.rf.2af43f0fe1ca2e2f3dac90bdee5876d0.jpg -------------------------------------------------------------------------------- /data/images/1253_png.rf.dfaf5beae6f28b8ab25cac8ca4626afc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1253_png.rf.dfaf5beae6f28b8ab25cac8ca4626afc.jpg -------------------------------------------------------------------------------- /data/images/1269_png.rf.542f482ae7b6ce89416dabf9d53c290c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1269_png.rf.542f482ae7b6ce89416dabf9d53c290c.jpg -------------------------------------------------------------------------------- /data/images/126_png.rf.3e5644bbcdce8bfcd57a8b25f258d5db.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/126_png.rf.3e5644bbcdce8bfcd57a8b25f258d5db.jpg -------------------------------------------------------------------------------- /data/images/127_png.rf.79576d96ac85d2eed2e4508e10596aac.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/127_png.rf.79576d96ac85d2eed2e4508e10596aac.jpg -------------------------------------------------------------------------------- /data/images/1280_png.rf.fdd6f25e9003fd756eb20a645e59fd0a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1280_png.rf.fdd6f25e9003fd756eb20a645e59fd0a.jpg -------------------------------------------------------------------------------- /data/images/1302_png.rf.dfc194d802573aea9246cc4e8eed5dfa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/1302_png.rf.dfc194d802573aea9246cc4e8eed5dfa.jpg -------------------------------------------------------------------------------- /data/images/133_png.rf.ae653945db0085ad8f340d62ef7e9f34.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/133_png.rf.ae653945db0085ad8f340d62ef7e9f34.jpg -------------------------------------------------------------------------------- /data/images/888_png.rf.209110ac16fb6f523aa136b16e92f92d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/888_png.rf.209110ac16fb6f523aa136b16e92f92d.jpg -------------------------------------------------------------------------------- /data/images/908_png.rf.1c8aed116f4fa92085a172cd9dc0e072.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/908_png.rf.1c8aed116f4fa92085a172cd9dc0e072.jpg -------------------------------------------------------------------------------- /data/images/921_png.rf.a7c01f333a6cfd51129a2c75016ae896.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/921_png.rf.a7c01f333a6cfd51129a2c75016ae896.jpg -------------------------------------------------------------------------------- /data/images/923_png.rf.2cd952d8016f9b0ec3d69ed4f215d347.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/923_png.rf.2cd952d8016f9b0ec3d69ed4f215d347.jpg -------------------------------------------------------------------------------- /data/images/925_png.rf.24c2ed106b6a36c8ddd9e256f327424b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/images/925_png.rf.24c2ed106b6a36c8ddd9e256f327424b.jpg -------------------------------------------------------------------------------- /data/outputs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/outputs/.DS_Store -------------------------------------------------------------------------------- /data/outputs/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /data/uploads/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/uploads/.DS_Store -------------------------------------------------------------------------------- /data/uploads/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /data/video_frames/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/video_frames/.DS_Store -------------------------------------------------------------------------------- /data/video_frames/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /data/video_output/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thepbordin/YOLOv5-Streamlit-Deployment/f82588f0fe4047c41fec6691ac1a6797d41a6166/data/video_output/.DS_Store -------------------------------------------------------------------------------- /data/video_output/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /models/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /packages.txt: -------------------------------------------------------------------------------- 1 | libgl1 2 | ffmpeg -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # YOLOv5 requirements 2 | # Usage: pip install -r requirements.txt 3 | 4 | # Base ---------------------------------------- 5 | matplotlib>=3.2.2 6 | numpy>=1.18.5 7 | opencv-python 8 | Pillow>=7.1.2 9 | PyYAML>=5.3.1 10 | requests>=2.23.0 11 | scipy>=1.4.1 # Google Colab version 12 | torch>=1.7.0 13 | torchvision>=0.8.1 14 | tqdm>=4.41.0 15 | protobuf<4.21.5 # https://github.com/ultralytics/yolov5/issues/8012 16 | ultralytics 17 | # Logging ------------------------------------- 18 | tensorboard>=2.4.1 19 | # wandb 20 | 21 | # Plotting ------------------------------------ 22 | pandas>=1.1.4 23 | seaborn>=0.11.0 24 | 25 | 26 | # Extras -------------------------------------- 27 | ipython # interactive notebook 28 | psutil # system utilization 29 | thop # FLOPs computation 30 | streamlit 31 | wget 32 | ffmpeg-python 33 | -------------------------------------------------------------------------------- /video_predict.py: -------------------------------------------------------------------------------- 1 | import os 2 | import os.path as osp 3 | import cv2 4 | from PIL import Image 5 | import streamlit as st 6 | 7 | 8 | def runVideo(model, video, vdo_view, warn): 9 | video_name = osp.basename(video) 10 | outputpath = osp.join('data/video_output', video_name) 11 | 12 | # Create A Dir to save Video Frames 13 | os.makedirs('data/video_frames', exist_ok=True) 14 | frames_dir = osp.join('data/video_frames', video_name) 15 | os.makedirs(frames_dir, exist_ok=True) 16 | cap = cv2.VideoCapture(video) 17 | frame_count = 0 18 | with st.spinner(text="Predicting..."): 19 | warn.warning( 20 | 'This is realtime prediction, If you wish to download the final prediction result wait until the process done.', icon="⚠️") 21 | while True: 22 | frame_count += 1 23 | ret, frame = cap.read() 24 | if ret == False: 25 | break 26 | frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) 27 | result = model(frame) 28 | result.render() 29 | image = Image.fromarray(result.ims[0]) 30 | vdo_view.image(image, caption='Current Model Prediction(s)') 31 | image.save(osp.join(frames_dir, f'{frame_count}.jpg')) 32 | cap.release() 33 | # convert frames in dir to a single video file 34 | os.system( 35 | f'ffmpeg -framerate 30 -i {frames_dir}/%d.jpg -c:v libx264 -pix_fmt yuv420p {outputpath}') 36 | # Clean up Frames Dir 37 | os.system(f'rm -rf {frames_dir}') 38 | 39 | # Display Video 40 | output_video = open(outputpath, 'rb') 41 | output_video_bytes = output_video.read() 42 | st.video(output_video_bytes) 43 | st.write("Model Prediction") 44 | vdo_view.empty() 45 | warn.empty() 46 | --------------------------------------------------------------------------------