Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
282 commits
Select commit Hold shift + click to select a range
ba9b730
Use local copy of image
DimaBir Dec 22, 2023
0ebbe3e
Use local copy of image
DimaBir Dec 22, 2023
c95d5d3
Use local copy of image
DimaBir Dec 22, 2023
18a8902
Use local copy of image
DimaBir Dec 22, 2023
fa08c2d
Transfer numpy array to the list before jsonoify
DimaBir Dec 22, 2023
0430c81
Transfer numpy array to the list before jsonoify
DimaBir Dec 22, 2023
b258b04
Transfer numpy array to the list before jsonoify
DimaBir Dec 22, 2023
78fe3a8
Revert "Transfer numpy array to the list before jsonoify"
DimaBir Dec 22, 2023
928c18d
Revert "Transfer numpy array to the list before jsonoify"
DimaBir Dec 22, 2023
86b98d5
Revert "Transfer numpy array to the list before jsonoify"
DimaBir Dec 22, 2023
42c1c24
Transfer numpy array to the list before jsonoify
DimaBir Dec 22, 2023
a89479d
Transfer numpy array to the list before jsonoify
DimaBir Dec 22, 2023
cbc7066
Big FIX: probability bug, fixed returning raw probability
DimaBir Dec 22, 2023
2b97cb4
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 22, 2023
7720d9f
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 22, 2023
1bbc5c5
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 22, 2023
b352a9e
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 22, 2023
561fc75
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 22, 2023
a2de416
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 22, 2023
0542548
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 22, 2023
c2d5722
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 23, 2023
edd00f9
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 23, 2023
abfe73d
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 23, 2023
542ffe4
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 23, 2023
760be19
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 23, 2023
3579f44
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 23, 2023
2e6bb1c
Refactored HTML added Image mini picture and prediction results as a …
DimaBir Dec 23, 2023
d06c608
Trying to apply image resize
DimaBir Dec 23, 2023
5edbcf3
Trying to apply image resize
DimaBir Dec 23, 2023
fd37f17
Trying to apply image resize
DimaBir Dec 23, 2023
fb1e864
Less transparent bars
DimaBir Dec 23, 2023
78e96db
Redesign
DimaBir Dec 23, 2023
2f4d04a
Redesign and adding inference time
DimaBir Dec 23, 2023
440f394
Redesign and adding inference time
DimaBir Dec 23, 2023
570a28d
Merge remote-tracking branch 'origin/web_demo' into web_demo
DimaBir Dec 23, 2023
e02418b
Revert "Redesign and adding inference time"
DimaBir Dec 23, 2023
4552743
Redesign and adding inference time
DimaBir Dec 23, 2023
acdd5ee
Redesign and adding inference time
DimaBir Dec 23, 2023
669b4c3
Fix displayPredictions
DimaBir Dec 23, 2023
9b1980f
Added styling
DimaBir Dec 23, 2023
8411783
Added styling
DimaBir Dec 23, 2023
ee9509f
Added styling
DimaBir Dec 23, 2023
fad4bd8
Added styling
DimaBir Dec 23, 2023
d2c8f1d
Horizontal page layout
DimaBir Dec 23, 2023
5fd7990
Revert "Horizontal page layout"
DimaBir Dec 23, 2023
e6e86b5
Added flash image
DimaBir Dec 23, 2023
5003ac7
Fixed get_top_predictions in all inference classes for accurate softm…
DimaBir Dec 23, 2023
793b14f
Fixed get_top_predictions in all inference classes for accurate softm…
DimaBir Dec 23, 2023
a1adf87
Fixed get_top_predictions for pytorch_inference.py
DimaBir Dec 23, 2023
f573cca
Fixed get_top_predictions for pytorch_inference.py
DimaBir Dec 23, 2023
7bb20a6
Fixed get_top_predictions for pytorch_inference.py
DimaBir Dec 23, 2023
78c3f32
Fixed get_top_predictions for pytorch_inference.py
DimaBir Dec 23, 2023
9b17947
Fixed pytorch_inference.py
DimaBir Dec 23, 2023
c49de6b
Added official preprocessor for input images
DimaBir Dec 23, 2023
f44c254
Added official preprocessor for input images
DimaBir Dec 23, 2023
b3fa695
Added official preprocessor for input images
DimaBir Dec 23, 2023
43a230d
Added prediction label to front end
DimaBir Dec 23, 2023
e80a7e2
Added prediction label to front end
DimaBir Dec 23, 2023
2e6f257
Added prediction label to front end
DimaBir Dec 23, 2023
c2f81ab
Color update
DimaBir Dec 23, 2023
b376d54
Color update
DimaBir Dec 23, 2023
328d25e
Color update
DimaBir Dec 23, 2023
b2ff85b
Color update
DimaBir Dec 23, 2023
b6f902a
Color update
DimaBir Dec 23, 2023
a640a8b
Try vertical layout
DimaBir Dec 23, 2023
b0a13e9
Try vertical layout
DimaBir Dec 23, 2023
5f5a523
Merge remote-tracking branch 'origin/web_demo' into web_demo
DimaBir Dec 23, 2023
1921e7d
Revert vertical layout
DimaBir Dec 23, 2023
ab75045
ONNXInference predict and get_top_predict fix
DimaBir Dec 23, 2023
c12637f
Made models in user form dynamically uploaded depending on mode choosen
DimaBir Dec 23, 2023
365e959
Made models in user form dynamically uploaded depending on mode choosen
DimaBir Dec 23, 2023
f2eb67c
Made models in user form dynamically uploaded depending on mode choosen
DimaBir Dec 23, 2023
2e37ccd
Fixed ONNX Inference predict
DimaBir Dec 23, 2023
95d9a86
Added color palette
DimaBir Dec 23, 2023
60bceb6
Added color palette
DimaBir Dec 23, 2023
f745c34
Added color palette
DimaBir Dec 23, 2023
6f7b5d1
Try vertical layout for mobile
DimaBir Dec 23, 2023
e0731a7
Try vertical layout for mobile
DimaBir Dec 23, 2023
5612de4
-- Try vertical layout for mobile
DimaBir Dec 23, 2023
b465cc2
Revert "-- Try vertical layout for mobile"
DimaBir Dec 23, 2023
b1b552d
Revert "Try vertical layout for mobile"
DimaBir Dec 23, 2023
82ac712
Revert "Try vertical layout for mobile"
DimaBir Dec 23, 2023
8810594
-- Try vertical layout for mobile
DimaBir Dec 23, 2023
7e9e8b7
-- Try vertical layout for mobile
DimaBir Dec 23, 2023
44ba4c9
-- Try vertical layout for mobile
DimaBir Dec 23, 2023
be2586a
-- Try vertical layout for mobile
DimaBir Dec 23, 2023
9ff361c
-- Try vertical layout for mobile
DimaBir Dec 23, 2023
745e35d
Fixed horizontalBar not registered
DimaBir Dec 23, 2023
abcb26b
Fixed horizontalBar not registered
DimaBir Dec 23, 2023
5f355c7
Enhanced UI with Animated Benchmark Info and Responsive Graphs
DimaBir Dec 24, 2023
7ef7aa4
Enhanced UI with Animated Benchmark Info and Responsive Graphs
DimaBir Dec 24, 2023
8513043
Enhanced UI with Animated Benchmark Info and Responsive Graphs
DimaBir Dec 24, 2023
c8414d8
Changed BG color
DimaBir Dec 24, 2023
81ae360
Fix bug of mode switch
DimaBir Dec 24, 2023
0c3387c
Fix bug of mode switch
DimaBir Dec 24, 2023
55b6c61
Fix bug of mode switch
DimaBir Dec 24, 2023
bec57b9
Fix bug of mode switch
DimaBir Dec 24, 2023
e00ef39
Fix bug of mode switch
DimaBir Dec 24, 2023
ee20059
Fix bug of mode switch
DimaBir Dec 24, 2023
43d7a37
Fix bug of mode switch
DimaBir Dec 24, 2023
5a73ca8
Fix bug of mode switch
DimaBir Dec 24, 2023
aef7fc5
Fix bug of mode switch
DimaBir Dec 24, 2023
fedc6f7
Background animation
DimaBir Dec 24, 2023
f7444a0
Integrated EfficientNet
DimaBir Dec 24, 2023
297e94e
Integrating model selector to FrontEnd and BackEnd
DimaBir Dec 24, 2023
1b327b5
Integrating model selector to FrontEnd and BackEnd
DimaBir Dec 24, 2023
578dc51
Added error messages support
DimaBir Dec 24, 2023
0643447
Fixing ModuleNotFoundError: No module named 'flask_limiter.exceptions'
DimaBir Dec 24, 2023
1e58f47
Fixing ModuleNotFoundError: No module named 'flask_limiter.exceptions'
DimaBir Dec 24, 2023
41715b7
Fixed error message fade
DimaBir Dec 24, 2023
f2f4ee8
Fixed error message fade. added close button
DimaBir Dec 24, 2023
f69fe37
Added info card
DimaBir Dec 24, 2023
651e72f
Added info card
DimaBir Dec 24, 2023
ec5baa4
Added info card
DimaBir Dec 24, 2023
5931584
Added info card
DimaBir Dec 24, 2023
c813fd2
Added info card
DimaBir Dec 24, 2023
965035a
Added info card
DimaBir Dec 24, 2023
116010d
Added info card
DimaBir Dec 24, 2023
d4cacfe
Revert "Added info card"
DimaBir Dec 24, 2023
29ad86b
Added info card
DimaBir Dec 24, 2023
00d6709
Added info card
DimaBir Dec 24, 2023
6b9707f
Added info card
DimaBir Dec 24, 2023
255c50b
Added info card
DimaBir Dec 24, 2023
8b42e3c
Added info card
DimaBir Dec 24, 2023
fd75bdb
Added info card
DimaBir Dec 24, 2023
2ad1e9e
Added info card
DimaBir Dec 24, 2023
9b5c423
Added info card
DimaBir Dec 24, 2023
73939eb
Added info card
DimaBir Dec 24, 2023
b3c0de6
Added info card
DimaBir Dec 24, 2023
4518b0a
Added inner card
DimaBir Dec 25, 2023
b9eef64
Added inner card
DimaBir Dec 25, 2023
bc72c4e
Adding footer and fixing benchmarks
DimaBir Dec 25, 2023
b9dc879
Fixing footer, sticking to the bottom
DimaBir Dec 25, 2023
8d0bf69
Fixing footer, sticking to the bottom
DimaBir Dec 25, 2023
2ac88a0
Revert "Fixing footer, sticking to the bottom"
DimaBir Dec 25, 2023
ccf0667
Revert "Fixing footer, sticking to the bottom"
DimaBir Dec 25, 2023
4cf0360
Revert "Adding footer and fixing benchmarks"
DimaBir Dec 25, 2023
8ab44d0
Fixing footer, sticking to the bottom
DimaBir Dec 25, 2023
7bd09a9
Fixing footer, sticking to the bottom
DimaBir Dec 25, 2023
dab6007
Revert "Fixing footer, sticking to the bottom"
DimaBir Dec 25, 2023
07c41f9
Revert "Fixing footer, sticking to the bottom"
DimaBir Dec 25, 2023
ea62944
Changed to subdomain infer.birenbaum.co with default port 8080
DimaBir Dec 29, 2023
95e15d0
Changed to subdomain infer.birenbaum.co with default port 8080
DimaBir Dec 29, 2023
eb078e0
Revert "Changed to subdomain infer.birenbaum.co with default port 8080"
DimaBir Dec 29, 2023
37fe749
Revert "Changed to subdomain infer.birenbaum.co with default port 8080"
DimaBir Dec 29, 2023
1983035
Changed to subdomain infer.birenbaum.co with default port 8080
DimaBir Dec 29, 2023
97c03d0
Changed to subdomain infer.birenbaum.co with default port 8080
DimaBir Dec 29, 2023
120293b
Revert "Changed to subdomain infer.birenbaum.co with default port 8080"
DimaBir Dec 29, 2023
4c5e8ab
Revert "Changed to subdomain infer.birenbaum.co with default port 8080"
DimaBir Dec 29, 2023
5b17cc2
Mapping default HTTPS host port (432) to the containers flask appp 5000
DimaBir Dec 29, 2023
b1f0af6
Mapping default HTTPS host port (432) to the containers flask appp 5000
DimaBir Dec 29, 2023
c09d906
Mapping default HTTPS host port (432) to the containers flask appp 5000
DimaBir Dec 29, 2023
e354c79
Mapping default HTTPS host port (432) to the containers flask appp 5000
DimaBir Dec 29, 2023
a81f1a0
Mapping default HTTPS host port (432) to the containers flask appp 5000
DimaBir Dec 29, 2023
abac3b5
Mapping default HTTPS host port (432) to the containers flask appp 5000
DimaBir Dec 29, 2023
502ef67
Added EfficientNet-B7
DimaBir Dec 29, 2023
e5d5ad3
Added threads support and UI update for new model
DimaBir Dec 29, 2023
e414012
Added threads support and UI update for new model
DimaBir Dec 29, 2023
f89f13d
Enhanced run_all_benchmarks with parallel execution and error handling
DimaBir Dec 30, 2023
7503b1c
Revert run_all_benchmarks optimizartion
DimaBir Dec 30, 2023
73ae56a
Revert "Revert run_all_benchmarks optimizartion"
DimaBir Dec 30, 2023
cfb29a4
Revert run_all_benchmarks optimizartion
DimaBir Dec 30, 2023
fa10e28
Debugging
DimaBir Dec 30, 2023
66a0888
Debugging
DimaBir Dec 30, 2023
5e34007
Debugging
DimaBir Dec 30, 2023
3eb3120
Debugging multithreading
DimaBir Dec 30, 2023
9eef59e
Debugging multithreading
DimaBir Dec 30, 2023
69ef5b5
Revert multithreading
DimaBir Dec 30, 2023
98e8f1f
Added OV FP 16 model fo the core logic
DimaBir Dec 30, 2023
1a615a7
Integrated OV FP 16 model to the FrontEnd
DimaBir Dec 30, 2023
583bce4
Integrated OV FP 16 model to the FrontEnd
DimaBir Dec 30, 2023
1aa2a06
(Debug) Integrated OV FP 16 model to the FrontEnd
DimaBir Dec 30, 2023
2240a62
Added FP16 input data conversion for predict. Cherry pick as well
DimaBir Dec 30, 2023
a26ddb9
Adding logs for debug
DimaBir Dec 30, 2023
cc4bc6d
(DEBUG) Adding logs for debug
DimaBir Dec 30, 2023
3b20ed8
(DEBUG) Adding logs for debug
DimaBir Dec 30, 2023
28b0efc
(DEBUG) Adding logs for debug
DimaBir Dec 30, 2023
5a92ef4
(DEBUG) Adding logs for debug
DimaBir Dec 30, 2023
0b26806
(DEBUG) Adding logs for debug
DimaBir Dec 30, 2023
140d2fd
(DEBUG) Adding logs for debug
DimaBir Dec 30, 2023
1486eed
(DEBUG) Adding precision
DimaBir Dec 30, 2023
2160fc4
(DEBUG) Adding precision
DimaBir Dec 30, 2023
3b65c60
(DEBUG) Adding precision
DimaBir Dec 30, 2023
6e4a117
(DEBUG) Adding precision
DimaBir Dec 30, 2023
bff9316
(DEBUG) Adding precision
DimaBir Dec 30, 2023
ed3f0a0
(DEBUG) Adding precision
DimaBir Dec 30, 2023
89c0f62
(DEBUG) Adding precision
DimaBir Dec 30, 2023
f89329f
(DEBUG) Adding precision
DimaBir Dec 30, 2023
5b5d936
(DEBUG) Adding precision
DimaBir Dec 30, 2023
cb94e49
(DEBUG) Adding precision
DimaBir Dec 30, 2023
413dc19
(DEBUG) Adding precision
DimaBir Dec 30, 2023
f630788
(DEBUG) Adding precision
DimaBir Dec 30, 2023
b72fedf
(DEBUG) Adding precision
DimaBir Dec 30, 2023
5862bab
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
b71f3bc
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
c310757
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
0e7faa9
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
86b7f62
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
828904e
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
eee8e97
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
d94fbe2
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
58df1f2
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
c3f0fee
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
633cfed
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
21e0944
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
47dd9b9
Revert "(DEBUG) Adding precision"
DimaBir Dec 30, 2023
87ddb49
Revert "(DEBUG) Adding logs for debug"
DimaBir Dec 30, 2023
64243c2
Revert "(DEBUG) Adding logs for debug"
DimaBir Dec 30, 2023
763b012
Revert "(DEBUG) Adding logs for debug"
DimaBir Dec 30, 2023
a7dd416
Revert "(DEBUG) Adding logs for debug"
DimaBir Dec 30, 2023
094b4e1
Revert "(DEBUG) Adding logs for debug"
DimaBir Dec 30, 2023
da8edae
Revert "(DEBUG) Adding logs for debug"
DimaBir Dec 30, 2023
07665d6
Revert "Adding logs for debug"
DimaBir Dec 30, 2023
7dbea51
Revert "Added FP16 input data conversion for predict. Cherry pick as …
DimaBir Dec 30, 2023
f94b215
Revert "(Debug) Integrated OV FP 16 model to the FrontEnd"
DimaBir Dec 30, 2023
7d05196
Revert "Integrated OV FP 16 model to the FrontEnd"
DimaBir Dec 30, 2023
6dd286c
Revert "Integrated OV FP 16 model to the FrontEnd"
DimaBir Dec 30, 2023
1c42e9e
Revert "Added OV FP 16 model fo the core logic"
DimaBir Dec 30, 2023
42a43b6
Revert "Added OV FP 16 model fo the core logic"
DimaBir Dec 30, 2023
bc3e556
Merge remote-tracking branch 'origin/web_demo' into web_demo
DimaBir Dec 30, 2023
ffd1b7a
Added MobileNet V2 to the core logic
DimaBir Dec 30, 2023
7b5d897
Updated front end for MobileNet V2 to the core logic
DimaBir Dec 30, 2023
56ddb92
For each CNN model added prefix to differentiate between saved models
DimaBir Dec 31, 2023
2aeb71d
Revert "For each CNN model added prefix to differentiate between save…
DimaBir Dec 31, 2023
cbabb53
For each CNN model added prefix to differentiate between saved models
DimaBir Dec 31, 2023
b0afd6f
Update README.md
DimaBir Jan 5, 2024
5c38762
added dcrag and drop
DimaBir Jan 6, 2024
73e9e72
added drag and drop
DimaBir Jan 6, 2024
ef00f85
added drag and drop
DimaBir Jan 6, 2024
830f9a5
Supporting drag and drop file
DimaBir Jan 6, 2024
557462f
Supporting drag and drop file
DimaBir Jan 6, 2024
75d8acf
Supporting drag and drop file
DimaBir Jan 6, 2024
bc54821
Supporting drag and drop file
DimaBir Jan 6, 2024
60c349c
Supporting drag and drop file
DimaBir Jan 6, 2024
c92ab38
Supporting drag and drop file
DimaBir Jan 6, 2024
ef828e6
Supporting drag and drop file
DimaBir Jan 6, 2024
22ef265
Revert "Supporting drag and drop file"
DimaBir Jan 6, 2024
df48d6e
Revert "Supporting drag and drop file"
DimaBir Jan 6, 2024
69b861f
Revert "Supporting drag and drop file"
DimaBir Jan 6, 2024
43e8a2c
Revert "Supporting drag and drop file"
DimaBir Jan 6, 2024
1ed298f
Revert "Supporting drag and drop file"
DimaBir Jan 6, 2024
f8d932f
Revert "Supporting drag and drop file"
DimaBir Jan 6, 2024
60f1673
Revert "Supporting drag and drop file"
DimaBir Jan 6, 2024
8809a53
Revert "added drag and drop"
DimaBir Jan 6, 2024
b0de56c
Revert "added drag and drop"
DimaBir Jan 6, 2024
e9bd9fb
Revert "added dcrag and drop"
DimaBir Jan 6, 2024
e254ca2
Add drag and drop
DimaBir Jan 6, 2024
0c7f8d3
Revert "Add drag and drop"
DimaBir Jan 6, 2024
c3b2964
Fixing Dockerfile
DimaBir Aug 21, 2024
f3dbae0
Removing usage of SSL cert
DimaBir Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Argument for base image. Default is a neutral Python image.
ARG BASE_IMAGE=python:3.8-slim
ARG BASE_IMAGE=python:3.10-slim

# Use the base image specified by the BASE_IMAGE argument
FROM $BASE_IMAGE
Expand Down
22 changes: 22 additions & 0 deletions Dockerfile.flask
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use an official Python runtime as a parent image
FROM python:3.10-slim

# Set the working directory in the container
WORKDIR /usr/src/app

# Copy the Flask app requirements file into the container at /usr/src/app
COPY requirements.flask.txt ./

# Install any needed packages specified in requirements.flask.txt
RUN pip install -r requirements.flask.txt

COPY ./src /usr/src/app/src
COPY ./common /usr/src/app/common
COPY ./inference /usr/src/app/inference

# Make port 5000 available to the world outside this container
EXPOSE 5000

# Define the command to run the Flask app
CMD ["python", "./src/web_demo/app.py"]
sudo docker
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

## Table of Contents
1. [Overview](#overview)
2. [Requirements](#requirements)
2. [Live Demo](#live-demo) ![New](https://img.shields.io/badge/-New-842E5B)
3. [Modularity and Extended Model Support](#modularity-and-extended-model-support) ![New](https://img.shields.io/badge/-New-842E5B)
4. [Requirements](#requirements)
- [Steps to Run](#steps-to-run)
- [Example Command](#example-command)
3. [Results](#results)
- [CPU Results](#cpu-results) ![Static Badge](https://img.shields.io/badge/update-orange)
- [GPU (CUDA) Results](#gpu-cuda-results) ![Static Badge](https://img.shields.io/badge/update-orange)
- [CPU Results M1 Pro](#cpu-results-m1-pro) ![New](https://img.shields.io/badge/-New-842E5B)
6. [Benchmark Implementation Details](#benchmark-implementation-details) ![New](https://img.shields.io/badge/-New-842E5B)
5. [Results](#results)
- [CPU Results](#cpu-results)
- [GPU (CUDA) Results](#gpu-cuda-results)
- [CPU Results M1 Pro](#cpu-results-m1-pro)
6. [Benchmark Implementation Details](#benchmark-implementation-details)
- [PyTorch CPU & CUDA](#pytorch-cpu--cuda)
- [TensorRT FP32 & FP16](#tensorrt-fp32--fp16)
- [ONNX](#onnx)
Expand All @@ -30,6 +32,16 @@ The project is Dockerized for easy deployment:

Refer to the [Steps to Run](#steps-to-run) section for Docker instructions.

## Live Demo
We have added a live demo feature to the project, allowing users to interact with the model through a web interface. The demo is built using Flask and can be easily accessed and used for real-time inference.

- [Live Demo](https://birenbaum.co:5000/demo)

## Modularity and Extended Model Support
The project now supports a range of models beyond the original ResNet-50. This modularity allows users to easily integrate and test different models for their specific use cases.

- Supported models include EfficientNet, MobileNet, and more.
- For details on adding new models, refer to [Model Loader](src/model.py).

## Requirements
- This repo cloned
Expand Down
24 changes: 24 additions & 0 deletions common/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import torch
import logging
import argparse
import pandas as pd
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -111,3 +113,25 @@ def parse_arguments():
)

return parser.parse_args()


def cuda_is_available() -> bool:
"""
Check the availability of CUDA and TensorRT on the system.

Determines if CUDA is available and if the 'torch_tensorrt' package is
installed. Logs a warning if 'torch_tensorrt' is not installed.

:return: True if CUDA is available and 'torch_tensorrt' is installed, False otherwise.
"""
cuda_available = False
if torch.cuda.is_available():
try:
import torch_tensorrt

cuda_available = True
except ImportError:
logging.warning(
"torch-tensorrt is not installed. Running on CPU mode only."
)
return cuda_available
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3'

services:
resnet_tensorrt:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000"

flask_app:
build:
context: .
dockerfile: Dockerfile.flask
ports:
- "5000:5000"
volumes:
- ./keys:/usr/src/app/keys
depends_on:
- resnet_tensorrt
17 changes: 17 additions & 0 deletions requirements.flask.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
torch
Flask
gunicorn
requests
Pillow
pandas
torchvision
pandas
numpy
packaging
onnx
onnxruntime
openvino==2023.1.0.dev20230811
seaborn
matplotlib
Flask-Limiter==1.5.0
Werkzeug==2.0.2
14 changes: 14 additions & 0 deletions src/image_processor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from torchvision import transforms
from torchvision.models import resnet50, ResNet50_Weights
from PIL import Image
import torch

Expand Down Expand Up @@ -38,3 +39,16 @@ def process_image(self) -> torch.Tensor:
img_batch = torch.unsqueeze(img_transformed, 0).to(self.device)

return img_batch

def process_image_official(self) -> torch.Tensor:
img = Image.open(self.img_path)

# Initialize the Weight Transforms
weights = ResNet50_Weights.DEFAULT
preprocess = weights.transforms()

# Apply it to the input image
img_transformed = preprocess(img)
img_batch = torch.unsqueeze(img_transformed, 0).to(self.device)

return img_batch
28 changes: 4 additions & 24 deletions src/inference_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def benchmark(self, input_data, num_runs=100, warmup_runs=50):
for img in input_batch:
self.predict(img.unsqueeze(0), is_benchmark=True)
avg_time = (
(time.time() - start_time) / (num_runs * self.batch_size)
) * 1000 # Convert to ms
(time.time() - start_time) / (num_runs * self.batch_size)
) * 1000 # Convert to ms

logging.info(f"Average inference time for {num_runs} runs: {avg_time:.4f} ms")
if self.debug_mode:
Expand All @@ -102,26 +102,6 @@ def benchmark(self, input_data, num_runs=100, warmup_runs=50):

return avg_time, throughput

def get_top_predictions(self, prob: np.ndarray, is_benchmark=False):
"""
Get the top predictions based on the probabilities.
def get_top_predictions(self, logits: np.ndarray, is_benchmark=False):
raise NotImplementedError

:param prob: Array of probabilities.
:param is_benchmark: If True, the method is called during a benchmark run.
:return: Array of probabilities.
"""
if is_benchmark:
return None

# Get the top indices and probabilities
top_indices = prob.argsort()[-self.topk :][::-1]
top_probs = prob[top_indices]

# Log and print the top predictions
for i in range(self.topk):
probability = top_probs[i]
class_label = self.categories[0][int(top_indices[i])]
logging.info(f"#{i + 1}: {int(probability * 100)}% {class_label}")
if self.debug_mode:
print(f"#{i + 1}: {int(probability * 100)}% {class_label}")
return prob
20 changes: 16 additions & 4 deletions src/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@


class ModelLoader:
def __init__(self, device: str = "cuda") -> None:
def __init__(self, model_type: str = "resnet50", device: str = "cuda") -> None:
"""
Initialize the ModelLoader object.

:param model_type: Type of the model to load ("resnet50", "efficientnet", etc.).
:param device: The device to load the model on ("cpu" or "cuda").
"""
self.model = models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V2).to(
device
)
self.device = device
self.model = self.load_model(model_type)
self.model_type = model_type
self.categories: pd.DataFrame = pd.read_csv(
"https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt",
header=None,
)

def load_model(self, model_type: str):
if model_type == "resnet50":
return models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V2).to(self.device)
elif model_type == "efficientnet_b0":
return models.efficientnet_b0(weights=models.EfficientNet_B0_Weights.IMAGENET1K_V1).to(self.device)
elif model_type == "efficientnet_b7":
return models.efficientnet_b7(weights=models.EfficientNet_B7_Weights.IMAGENET1K_V1).to(self.device)
elif model_type == "mobilenet_v2":
return models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1).to(self.device)
else:
raise ValueError(f"Unsupported model type: {model_type}")
34 changes: 32 additions & 2 deletions src/onnx_inference.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import torch
import torch.nn.functional as F
import logging
import onnxruntime as ort
import numpy as np
Expand Down Expand Up @@ -44,12 +46,13 @@ def predict(self, input_data, is_benchmark=False):
ort_inputs = {input_name: input_data.cpu().numpy()}
ort_outs = self.model.run(None, ort_inputs)

# Extract probabilities from the output and normalize them
# Extract probabilities from the output
if len(ort_outs) > 0:
prob = ort_outs[0]
if prob.ndim > 1:
prob = prob[0]
prob = np.exp(prob) / np.sum(np.exp(prob))
prob = F.softmax(torch.from_numpy(prob), dim=0).numpy()

return self.get_top_predictions(prob, is_benchmark)

def benchmark(self, input_data, num_runs=100, warmup_runs=50):
Expand All @@ -62,3 +65,30 @@ def benchmark(self, input_data, num_runs=100, warmup_runs=50):
:return: Average inference time in milliseconds.
"""
return super().benchmark(input_data, num_runs, warmup_runs)

def get_top_predictions(self, prob: np.ndarray, is_benchmark=False):
"""
Get the top predictions based on the probabilities.

:param prob: Array of probabilities.
:param is_benchmark: If True, the method is called during a benchmark run.
:return: List of dictionaries with label and confidence.
"""
if is_benchmark:
return None

# Get the top indices and probabilities
top_indices = prob.argsort()[-self.topk:][::-1]
top_probs = prob[top_indices]

# Prepare the list of predictions
predictions = []
for i in range(self.topk):
probability = top_probs[i]
class_label = self.categories[0][int(top_indices[i])]
predictions.append({"label": class_label, "confidence": float(probability)})

# Log the top predictions
logging.info(f"#{i + 1}: {probability * 100:.2f}% {class_label}")

return predictions
32 changes: 30 additions & 2 deletions src/ov_inference.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import os
import logging
import torch
import torch.nn.functional as F
import numpy as np
import openvino as ov
from src.inference_base import InferenceBase
Expand Down Expand Up @@ -52,10 +55,12 @@ def predict(self, input_data, is_benchmark=False):
input_name = next(iter(self.compiled_model.inputs))
outputs = self.compiled_model(inputs={input_name: input_data.cpu().numpy()})

# Extract probabilities from the output and normalize them
# Extract probabilities from the output
prob_key = next(iter(outputs))
prob = outputs[prob_key]
prob = np.exp(prob[0]) / np.sum(np.exp(prob[0]))

# Apply softmax to the probabilities
prob = F.softmax(torch.from_numpy(prob[0]), dim=0).numpy()

return self.get_top_predictions(prob, is_benchmark)

Expand All @@ -69,3 +74,26 @@ def benchmark(self, input_data, num_runs=100, warmup_runs=50):
:return: Average inference time in milliseconds.
"""
return super().benchmark(input_data, num_runs, warmup_runs)

def get_top_predictions(self, prob: np.ndarray, is_benchmark=False):
"""
Get the top predictions based on the probabilities.
"""
if is_benchmark:
return None

# Get the top indices and probabilities
top_indices = prob.argsort()[-self.topk :][::-1]
top_probs = prob[top_indices]

# Prepare the list of predictions
predictions = []
for i in range(self.topk):
probability = top_probs[i]
class_label = self.categories[0][int(top_indices[i])]
predictions.append({"label": class_label, "confidence": float(probability)})

# Log the top predictions
logging.info(f"#{i + 1}: {probability * 100:.2f}% {class_label}")

return predictions
37 changes: 32 additions & 5 deletions src/pytorch_inference.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import torch
import torch.nn.functional as F
import logging
import numpy as np
from src.inference_base import InferenceBase


Expand Down Expand Up @@ -37,11 +40,8 @@ def predict(self, input_data, is_benchmark=False):
with torch.no_grad():
outputs = self.model(input_data.to(self.device))

# Compute the softmax probabilities
prob = torch.nn.functional.softmax(outputs[0], dim=0)
prob = prob.cpu().numpy()

return self.get_top_predictions(prob, is_benchmark)
# Pass the raw output tensor to get_top_predictions
return self.get_top_predictions(outputs, is_benchmark)

def benchmark(self, input_data, num_runs=100, warmup_runs=50):
"""
Expand All @@ -53,3 +53,30 @@ def benchmark(self, input_data, num_runs=100, warmup_runs=50):
:return: Average inference time in milliseconds.
"""
return super().benchmark(input_data, num_runs, warmup_runs)

def get_top_predictions(self, output_tensor, is_benchmark=False):
"""
Get the top predictions based on the model's output.
"""
if is_benchmark:
return None

# Apply softmax to convert logits to probabilities
probabilities = F.softmax(output_tensor, dim=1)

# Get the top probabilities and their indices
top_probs, top_indices = torch.topk(probabilities, self.topk)
top_probs = top_probs[0].tolist()
top_indices = top_indices[0].tolist()

# Prepare the list of predictions
predictions = []
for i in range(self.topk):
probability = top_probs[i]
class_label = self.categories[0][top_indices[i]]
predictions.append({"label": class_label, "confidence": float(probability)})

# Log the top predictions
logging.info(f"#{i + 1}: {probability * 100:.2f}% {class_label}")

return predictions
Loading