RafidMehda commited on
Commit
4d8e57a
·
verified ·
1 Parent(s): 36e3dbb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -3,6 +3,17 @@ import numpy as np
3
  import streamlit as st
4
  import io
5
 
 
 
 
 
 
 
 
 
 
 
 
6
  # Logistic map function
7
  def logistic_map(r, x):
8
  return r * x * (1 - x)
@@ -34,11 +45,16 @@ def main():
34
  if uploaded_file is not None:
35
  # Load the uploaded image
36
  input_image = Image.open(uploaded_file)
37
- img_array = np.array(input_image)
 
 
38
 
39
  # Display original image
40
  st.image(input_image, caption="Uploaded Image", use_container_width=True)
41
 
 
 
 
42
  # Key input
43
  key_seed = st.slider("Set the encryption key seed (0 < key < 1)", min_value=0.001, max_value=0.999, step=0.001)
44
 
 
3
  import streamlit as st
4
  import io
5
 
6
+ # Resize image to prevent memory issues with large images
7
+ def resize_image(img, max_size=(3000, 3000)):
8
+ """
9
+ Resize image to fit within max_size while maintaining aspect ratio.
10
+ :param img: PIL Image object
11
+ :param max_size: Maximum dimensions (width, height)
12
+ :return: Resized PIL Image object
13
+ """
14
+ img.thumbnail(max_size, Image.ANTIALIAS)
15
+ return img
16
+
17
  # Logistic map function
18
  def logistic_map(r, x):
19
  return r * x * (1 - x)
 
45
  if uploaded_file is not None:
46
  # Load the uploaded image
47
  input_image = Image.open(uploaded_file)
48
+
49
+ # Resize the image if necessary
50
+ input_image = resize_image(input_image)
51
 
52
  # Display original image
53
  st.image(input_image, caption="Uploaded Image", use_container_width=True)
54
 
55
+ # Convert image to numpy array
56
+ img_array = np.array(input_image)
57
+
58
  # Key input
59
  key_seed = st.slider("Set the encryption key seed (0 < key < 1)", min_value=0.001, max_value=0.999, step=0.001)
60