eaglelandsonce commited on
Commit
02a2ae0
·
verified ·
1 Parent(s): d3bf0e4

Create 2_Agentic.py

Browse files
Files changed (1) hide show
  1. pages/2_Agentic.py +42 -0
pages/2_Agentic.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+
4
+ # Placeholder image setup
5
+ placeholder_images = [
6
+ Image.open('data/image1.jpg'), # Replace 'image1.jpg' with your placeholder image paths
7
+ Image.open('data/image2.jpg'),
8
+ Image.open('data/image3.jpg'),
9
+ Image.open('data/image4.jpg'),
10
+ Image.open('data/image5.jpg')
11
+ ]
12
+
13
+ def rearrange(order):
14
+ dynamic_container = st.container()
15
+
16
+ new_image_order = [placeholder_images[int(o) - 1] for o in order if o.isdigit() and 0 < int(o) <= len(placeholder_images)]
17
+ new_input_order = [st.session_state.get(f"input_{o}", "") for o in order if o.isdigit() and 0 < int(o) <= len(placeholder_images)]
18
+ new_output_order = [st.session_state.get(f"output_{o}", "") for o in order if o.isdigit() and 0 < int(o) <= len(placeholder_images)]
19
+
20
+ # Update display
21
+ for i, o in enumerate(order):
22
+ if o.isdigit() and 0 < int(o) <= len(placeholder_images):
23
+ cols = dynamic_container.columns(3)
24
+ cols[0].image(new_image_order[i], width=100)
25
+ input_key = f"input_{o}_{i}" # Ensure unique key by including both order and index
26
+ output_key = f"output_{o}_{i}" # Ensure unique key by including both order and index
27
+ cols[1].text_input(f"Input {o}", value=new_input_order[i], key=input_key)
28
+ cols[2].text_area(f"Output {o}", value=new_output_order[i], height=100, key=output_key)
29
+
30
+ st.title("Image Rearrangement App")
31
+
32
+ # Overall Input
33
+ order = st.text_input("Enter image order (e.g., 12345, 112, 54321)", key="order_input")
34
+
35
+ # Validate order input
36
+ valid_order = order and all(o.isdigit() and 0 < int(o) <= len(placeholder_images) for o in order)
37
+
38
+ if valid_order:
39
+ # Call the rearrange function when data is present and valid
40
+ rearrange(order)
41
+ else:
42
+ st.error("Please enter a valid order using numbers 1-5, which can be repeated or less than 5 characters long.")