ITSAIDI commited on
Commit
ab1449b
1 Parent(s): 4e2c209
Files changed (2) hide show
  1. App.py +5 -2
  2. utilitis.py +17 -0
App.py CHANGED
@@ -1,5 +1,5 @@
1
  import streamlit as st
2
- from utilitis import Draw,Add_Results
3
  from PIL import Image
4
 
5
  st.title("Bienvenue à Textra Web App")
@@ -8,13 +8,16 @@ st.write("(PNG, JPG, JPEG)")
8
  uploaded_file = st.file_uploader("Ou selectioner une image:", type=["png", "jpg", "jpeg"], accept_multiple_files=False)
9
 
10
  if uploaded_file is not None:
 
 
 
11
  image = Image.open(uploaded_file)
12
  image = image.convert("RGB")
13
  image,Results = Draw(image)
14
  #st.write("Predicted Text:",type(image))
15
  st.image(image, caption="Uploaded Image", use_column_width=True)
16
  st.sidebar.title('Results')
17
- st.sidebar.table(Results)
18
  Add_Results(Results)
19
 
20
 
 
1
  import streamlit as st
2
+ from utilitis import Draw,Add_Results,Change_Image
3
  from PIL import Image
4
 
5
  st.title("Bienvenue à Textra Web App")
 
8
  uploaded_file = st.file_uploader("Ou selectioner une image:", type=["png", "jpg", "jpeg"], accept_multiple_files=False)
9
 
10
  if uploaded_file is not None:
11
+ image_initiale = Image.open(uploaded_file)
12
+ image_initiale = image_initiale.convert("RGB")
13
+
14
  image = Image.open(uploaded_file)
15
  image = image.convert("RGB")
16
  image,Results = Draw(image)
17
  #st.write("Predicted Text:",type(image))
18
  st.image(image, caption="Uploaded Image", use_column_width=True)
19
  st.sidebar.title('Results')
20
+ Change_Image(image,image_initiale)
21
  Add_Results(Results)
22
 
23
 
utilitis.py CHANGED
@@ -160,3 +160,20 @@ def Add_Results(data):
160
 
161
  #############################################################################
162
  #############################################################################
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
  #############################################################################
162
  #############################################################################
163
+ def Change_Image(image1,image2):
164
+ # Initialize session state
165
+ if 'current_image' not in st.session_state:
166
+ st.session_state.current_image = 'image1'
167
+
168
+ # Button to switch between images
169
+ if st.button('Image'):
170
+ if st.session_state.current_image == 'image1':
171
+ st.session_state.current_image = 'image2'
172
+ else:
173
+ st.session_state.current_image = 'image1'
174
+
175
+ # Display the selected image
176
+ if st.session_state.current_image == 'image1':
177
+ st.image(image1, caption='Output', use_column_width=True)
178
+ else:
179
+ st.image(image2, caption='Image initiale', use_column_width=True)