Sayed121 commited on
Commit
f51c6c3
·
1 Parent(s): 902ba48

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -22
app.py CHANGED
@@ -131,33 +131,32 @@ def sample_images():
131
  st.header("Sample Images")
132
 
133
  # Sample images
134
- sample_images = {
135
  "Sample 1": "img_0002.jpg",
136
  }
137
 
138
  # Button to load sample images
139
  if st.button("Load Sample Images"):
140
- for sample_name, sample_path in sample_images.items():
141
- st.subheader(sample_name)
142
- sample_image = Image.open(sample_path).convert('RGB')
143
- st.image(sample_image, caption=f"{sample_name} Image.", use_column_width=True)
144
-
145
- # Text input for each sample image
146
- text_input = st.text_area(f"Input Question for {sample_name}:")
147
-
148
- # Predict button for each sample image
149
- if st.button(f"Predict {sample_name}"):
150
- if text_input:
151
- # Perform prediction
152
- prediction_result = predict(sample_image, text_input)
153
-
154
- # Display input text
155
- st.subheader(f"Input Question for {sample_name}:")
156
- st.write(text_input)
157
-
158
- # Display prediction result
159
- st.subheader(f"Prediction Result for {sample_name}:")
160
- st.write(prediction_result)
161
 
162
  def upload_image():
163
  st.header("Upload Image")
 
131
  st.header("Sample Images")
132
 
133
  # Sample images
134
+ example_image = {
135
  "Sample 1": "img_0002.jpg",
136
  }
137
 
138
  # Button to load sample images
139
  if st.button("Load Sample Images"):
140
+
141
+ sample_image = Image.open(example_image).convert('RGB')
142
+ st.image(sample_image, caption=f"{sample_name} Image.", use_column_width=True)
143
+
144
+ # Text input for each sample image
145
+ text_input = st.text_area(f"Input Question for {sample_name}:")
146
+
147
+ # Predict button for each sample image
148
+ if st.button(f"Predict"):
149
+ if text_input:
150
+ # Perform prediction
151
+ prediction_result = predict(sample_image, text_input)
152
+
153
+ # Display input text
154
+ st.subheader(f"Input Question for {"Example Image"}:")
155
+ st.write(text_input)
156
+
157
+ # Display prediction result
158
+ st.subheader(f"Prediction Result for {"Example Image"}:")
159
+ st.write(prediction_result)
 
160
 
161
  def upload_image():
162
  st.header("Upload Image")