Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from ultralyticsplus import YOLO, render_result
|
3 |
+
import cv2
|
4 |
+
import tempfile
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
# Title of the Streamlit app
|
8 |
+
st.title("Stock Market Future Prediction")
|
9 |
+
|
10 |
+
# Instructions
|
11 |
+
st.write("Upload an image and the model will predict future stock market trends.")
|
12 |
+
|
13 |
+
# Upload an image
|
14 |
+
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
15 |
+
|
16 |
+
if uploaded_file is not None:
|
17 |
+
# Save the uploaded file to a temporary location
|
18 |
+
with tempfile.NamedTemporaryFile(delete=False) as temp:
|
19 |
+
temp.write(uploaded_file.read())
|
20 |
+
temp_image_path = temp.name
|
21 |
+
|
22 |
+
# Display the uploaded image
|
23 |
+
image = Image.open(uploaded_file)
|
24 |
+
st.image(image, caption='Uploaded Image', use_column_width=True)
|
25 |
+
|
26 |
+
# Load model
|
27 |
+
model = YOLO('foduucom/stockmarket-future-prediction')
|
28 |
+
|
29 |
+
# Set model parameters
|
30 |
+
model.overrides['conf'] = 0.25 # NMS confidence threshold
|
31 |
+
model.overrides['iou'] = 0.45 # NMS IoU threshold
|
32 |
+
model.overrides['agnostic_nms'] = False # NMS class-agnostic
|
33 |
+
model.overrides['max_det'] = 1000 # maximum number of detections per image
|
34 |
+
|
35 |
+
# Perform inference
|
36 |
+
results = model.predict(temp_image_path)
|
37 |
+
|
38 |
+
# Display results
|
39 |
+
st.write("Prediction Results:")
|
40 |
+
st.write(results[0].boxes)
|
41 |
+
|
42 |
+
# Render and display the result
|
43 |
+
render = render_result(model=model, image=temp_image_path, result=results[0])
|
44 |
+
render_image = Image.fromarray(cv2.cvtColor(render.img, cv2.COLOR_BGR2RGB))
|
45 |
+
st.image(render_image, caption='Result Image', use_column_width=True)
|