Spaces:
Running
Running
File size: 1,559 Bytes
fd067cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
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)
|