Computer Vision News - July 2021

3 Summary 11 Turn Your CV Project into an App import cv2 from sklearn.datasets import make_blobs from sklearn.cluster import KMeans import matplotlib.pyplot as plt import streamlit as st import random from PIL import Image def upload_image (selection): if selection == "Upload your own": filename = st.sidebar.file_uploader( "Choose File", type=["png", "jpg", "jpeg"]) else : filename = "exampleyolo.jpeg" return filename def main (): st.sidebar.title("What to do") app_mode = st.sidebar.selectbox("Choose the app mode", ["Run k-means clustering", "Run object detection"]) image_selection = st.sidebar.selectbox("Choose the image", ["Upload your own", "Use example"]) if app_mode == "Run k-means clustering": image_filename = upload_image(image_selection) run_kmeans(image_filename) elif app_mode == "Run object detection": image_filename = upload_image(image_selection) run_detection(image_filename) # Cached function that returns a mutable object with a random number in the range 0-100 @st.cache (allow_output_mutation=True) def seed (): return {'seed': random.randint( 0 , 100 )} # Mutable (dict) # This is the function that runs the k-means algorithm itself, which appears when the user selects "Run k-means clustering". def run_kmeans (file_uploaded): st.header("K-means clustering app")

RkJQdWJsaXNoZXIy NTc3NzU=