import streamlit as st from ultralyticsplus import YOLO, render_result import cv2 import tempfile from PIL import Image # Title of the Streamlit app st.title("Stock Market Future Prediction") # Instructions st.write("Upload an image and the model will predict future stock market trends.") # Upload an image uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"]) if uploaded_file is not None: # Save the uploaded file to a temporary location with tempfile.NamedTemporaryFile(delete=False) as temp: temp.write(uploaded_file.read()) temp_image_path = temp.name # Display the uploaded image image = Image.open(uploaded_file) st.image(image, caption='Uploaded Image', use_column_width=True) # Load model model = YOLO('foduucom/stockmarket-future-prediction') # Set model parameters model.overrides['conf'] = 0.25 # NMS confidence threshold model.overrides['iou'] = 0.45 # NMS IoU threshold model.overrides['agnostic_nms'] = False # NMS class-agnostic model.overrides['max_det'] = 1000 # maximum number of detections per image # Perform inference results = model.predict(temp_image_path) # Display results st.write("Prediction Results:") st.write(results[0].boxes) # Render and display the result render = render_result(model=model, image=temp_image_path, result=results[0]) render_image = Image.fromarray(cv2.cvtColor(render.img, cv2.COLOR_BGR2RGB)) st.image(render_image, caption='Result Image', use_column_width=True)