OmidSakaki commited on
Commit
6e0a5f6
Β·
verified Β·
1 Parent(s): afa7c94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -23,8 +23,7 @@ st.set_page_config(
23
  initial_sidebar_state="expanded",
24
  )
25
 
26
- top_image = Image.open('banner_top.png')
27
- bottom_image = Image.open('banner_bottom.png')
28
  main_image = Image.open('main_banner.png')
29
 
30
  upload_path = ""
@@ -119,23 +118,34 @@ def FINAL(img) :
119
 
120
  Plot_Result(img, raw_plate, digits)
121
 
 
 
122
  if selected_type == "Upload Image":
123
  st.info('✨ Supports all popular image formats πŸ“· - PNG, JPG, BMP πŸ˜‰')
124
  uploaded_file = st.file_uploader("Upload Image of car's number plate πŸš“", type=["png","jpg","bmp","jpeg"])
125
 
126
  if uploaded_file is not None:
 
 
 
 
 
127
 
128
- image = Image.open(uploaded_file).convert('RGB')
129
- st.image(image, use_column_width=True)
130
-
131
- cv2.imwrite('inpout_img.jpg', image)
132
 
133
- image = cv2.imread('inpout_img.jpg')
 
 
 
 
134
 
135
- with st.spinner(f"Working... πŸ’«"):
136
- result = FINAL(image)
 
 
137
 
138
- st.image(result)
139
 
140
  #with st.spinner(f"Working... πŸ’«"):
141
  # uploaded_image = os.path.abspath(os.path.join(upload_path,uploaded_file.name))
 
23
  initial_sidebar_state="expanded",
24
  )
25
 
26
+ top_image = Image.open('favicon.ico')
 
27
  main_image = Image.open('main_banner.png')
28
 
29
  upload_path = ""
 
118
 
119
  Plot_Result(img, raw_plate, digits)
120
 
121
+
122
+
123
  if selected_type == "Upload Image":
124
  st.info('✨ Supports all popular image formats πŸ“· - PNG, JPG, BMP πŸ˜‰')
125
  uploaded_file = st.file_uploader("Upload Image of car's number plate πŸš“", type=["png","jpg","bmp","jpeg"])
126
 
127
  if uploaded_file is not None:
128
+ with open(os.path.join(upload_path,uploaded_file.name),"wb") as f:
129
+ f.write((uploaded_file).getbuffer())
130
+ with st.spinner(f"Working... πŸ’«"):
131
+ uploaded_image = os.path.abspath(os.path.join(upload_path,uploaded_file.name))
132
+ downloaded_image = os.path.abspath(os.path.join(download_path,str("output_"+uploaded_file.name)))
133
 
134
+ with open(uploaded_image,'rb') as imge:
135
+ img_bytes = imge.read()
 
 
136
 
137
+ img = Image.open(io.BytesIO(img_bytes))
138
+ results = FINAL(img)
139
+ for img in results:
140
+ img_base64 = Image.fromarray(img)
141
+ img_base64.save(downloaded_image, format="JPEG")
142
 
143
+ final_image = Image.open(downloaded_image)
144
+ print("Opening ",final_image)
145
+ st.markdown("---")
146
+ st.image(final_image, caption='This is how your final image looks like πŸ˜‰')
147
 
148
+
149
 
150
  #with st.spinner(f"Working... πŸ’«"):
151
  # uploaded_image = os.path.abspath(os.path.join(upload_path,uploaded_file.name))