Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
from PIL import ImageOps, Image
|
3 |
import os # To work with operation system commands
|
4 |
import cv2 # To process images
|
@@ -63,15 +64,16 @@ def Sort_Digits(result2) :
|
|
63 |
|
64 |
raw_plate = ('raw_plate.png')
|
65 |
|
66 |
-
def FINAL(
|
67 |
'''
|
68 |
A pipeline for all parts of phase 3.
|
69 |
start with a car image.
|
70 |
result is digits and char on car plate.
|
71 |
'''
|
72 |
# Read car image ( STEP-1 )
|
73 |
-
img = cv2.imread(
|
74 |
-
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
|
|
75 |
|
76 |
# First prediction -> Detect car-plate ( STEP-2 )
|
77 |
result1, _ = Detect_Plate(img)
|
@@ -83,7 +85,7 @@ def FINAL(img_path) :
|
|
83 |
img2 = img[round(pts[1]):round(pts[3]), round(pts[0]):round(pts[2])]
|
84 |
|
85 |
# Resize plate to feed to second model ( STEP-4 )
|
86 |
-
img2 =
|
87 |
|
88 |
# Second prediction -> Detect digits in plate
|
89 |
result2, _ = Detect_Digits(img2)
|
@@ -104,8 +106,8 @@ img = st.file_uploader('', type=['jpeg', 'jpg', 'png'])
|
|
104 |
|
105 |
# display image
|
106 |
if img is not None:
|
107 |
-
image = Image.open(img)
|
108 |
st.image(image, use_column_width=True)
|
109 |
|
110 |
|
111 |
-
st.write(FINAL(
|
|
|
1 |
import streamlit as st
|
2 |
+
import tensorflow as tf
|
3 |
from PIL import ImageOps, Image
|
4 |
import os # To work with operation system commands
|
5 |
import cv2 # To process images
|
|
|
64 |
|
65 |
raw_plate = ('raw_plate.png')
|
66 |
|
67 |
+
def FINAL(img) :
|
68 |
'''
|
69 |
A pipeline for all parts of phase 3.
|
70 |
start with a car image.
|
71 |
result is digits and char on car plate.
|
72 |
'''
|
73 |
# Read car image ( STEP-1 )
|
74 |
+
#img = cv2.imread(img)
|
75 |
+
#img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
76 |
+
img = Image.open(img).convert('RGB')
|
77 |
|
78 |
# First prediction -> Detect car-plate ( STEP-2 )
|
79 |
result1, _ = Detect_Plate(img)
|
|
|
85 |
img2 = img[round(pts[1]):round(pts[3]), round(pts[0]):round(pts[2])]
|
86 |
|
87 |
# Resize plate to feed to second model ( STEP-4 )
|
88 |
+
img2 = tf.image.resize(img2, (120, 70))
|
89 |
|
90 |
# Second prediction -> Detect digits in plate
|
91 |
result2, _ = Detect_Digits(img2)
|
|
|
106 |
|
107 |
# display image
|
108 |
if img is not None:
|
109 |
+
image = Image.open(img).convert('RGB')
|
110 |
st.image(image, use_column_width=True)
|
111 |
|
112 |
|
113 |
+
st.write(FINAL(img))
|