Spaces:
Runtime error
Runtime error
import streamlit as st | |
from PIL import Image | |
from utils import generate, opencv_to_pil | |
algorithm_choices = [ | |
"Sobel Edge Detection", | |
"Canny Edge Detection", | |
# "Hough Lines", | |
"Laplacian Edge Detection", | |
# "Contours Detection", | |
"Prewitt Edge Detection", | |
"Gradient Magnitude", | |
# "Corner Detection", | |
] | |
def main(): | |
st.title("Line Detection Algorithms") | |
st.write("Upload an image and select a line detection algorithm.") | |
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"]) | |
algorithm_choice = st.selectbox( | |
"Select Line Detection Algorithm", algorithm_choices | |
) | |
if uploaded_file is not None: | |
image = Image.open(uploaded_file) | |
st.image(image, caption="Uploaded Image", use_column_width=True) | |
if st.button("Generate Output"): | |
output = generate(image, algorithm_choice) | |
result = opencv_to_pil(output) | |
st.image(result, caption="Generated Output", use_column_width=True) | |
if __name__ == "__main__": | |
main() | |