Update app.py
Browse files
app.py
CHANGED
|
@@ -42,20 +42,25 @@ input_prompt = textwrap.dedent("""
|
|
| 42 |
""")
|
| 43 |
|
| 44 |
# Display sample input images
|
| 45 |
-
sample_images_folder = pathlib.Path(__file__).parent / "
|
| 46 |
sample_images = [sample_image.name for sample_image in sample_images_folder.glob("*.jpg") if sample_image.is_file()]
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
| 51 |
-
uploaded_file = sample_image_uploaded
|
| 52 |
-
else:
|
| 53 |
-
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 54 |
|
| 55 |
-
image = ""
|
| 56 |
if uploaded_file is not None:
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
submit = st.button("Submit")
|
| 61 |
|
|
|
|
| 42 |
""")
|
| 43 |
|
| 44 |
# Display sample input images
|
| 45 |
+
sample_images_folder = pathlib.Path(__file__).parent / "sample_images"
|
| 46 |
sample_images = [sample_image.name for sample_image in sample_images_folder.glob("*.jpg") if sample_image.is_file()]
|
| 47 |
|
| 48 |
+
sample_image_selected = st.sidebar.selectbox("Choose a sample image", sample_images)
|
| 49 |
|
| 50 |
+
uploaded_file = st.sidebar.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
|
|
|
|
|
|
|
|
|
| 51 |
|
|
|
|
| 52 |
if uploaded_file is not None:
|
| 53 |
+
if sample_image_selected:
|
| 54 |
+
sample_image_path = sample_images_folder / sample_image_selected
|
| 55 |
+
uploaded_file.name = sample_image_selected
|
| 56 |
+
uploaded_file.seek(0)
|
| 57 |
+
with open(sample_image_path, "wb") as f:
|
| 58 |
+
f.write(uploaded_file.read())
|
| 59 |
+
image = Image.open(sample_image_path)
|
| 60 |
+
st.image(image, caption="Uploaded Image.", use_column_width=True)
|
| 61 |
+
else:
|
| 62 |
+
image = Image.open(uploaded_file)
|
| 63 |
+
st.image(image, caption="Uploaded Image.", use_column_width=True)
|
| 64 |
|
| 65 |
submit = st.button("Submit")
|
| 66 |
|