Spaces:
Sleeping
Sleeping
mistermprah
commited on
Commit
•
13fdc8c
1
Parent(s):
86bd1a4
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,8 @@ import yfinance as yf
|
|
6 |
from datetime import datetime
|
7 |
from tensorflow.keras.models import load_model
|
8 |
from joblib import load
|
|
|
|
|
9 |
|
10 |
# Load the saved LSTM model and scaler
|
11 |
lstm_model = load_model('lstm_model.h5')
|
@@ -71,9 +73,12 @@ def predict_stock_price(ticker, open_price, high_price, low_price, close_price,
|
|
71 |
buf.seek(0)
|
72 |
plt.close()
|
73 |
|
|
|
|
|
|
|
74 |
result = f"Predicted future price for {ticker}: ${next_day_lstm_price:.2f}"
|
75 |
|
76 |
-
return result,
|
77 |
except Exception as e:
|
78 |
return str(e)
|
79 |
|
@@ -105,7 +110,7 @@ iface = gr.Interface(
|
|
105 |
gr.Number(label="Adj Close"),
|
106 |
gr.Number(label="Volume")
|
107 |
],
|
108 |
-
outputs=[gr.Textbox(), gr.Image(type="
|
109 |
title="Stock Price Predictor",
|
110 |
description="Select the stock ticker and input the last recorded values to predict the closing price using the LSTM model."
|
111 |
)
|
|
|
6 |
from datetime import datetime
|
7 |
from tensorflow.keras.models import load_model
|
8 |
from joblib import load
|
9 |
+
import io
|
10 |
+
from PIL import Image
|
11 |
|
12 |
# Load the saved LSTM model and scaler
|
13 |
lstm_model = load_model('lstm_model.h5')
|
|
|
73 |
buf.seek(0)
|
74 |
plt.close()
|
75 |
|
76 |
+
# Load the image from the buffer
|
77 |
+
img = Image.open(buf)
|
78 |
+
|
79 |
result = f"Predicted future price for {ticker}: ${next_day_lstm_price:.2f}"
|
80 |
|
81 |
+
return result, img
|
82 |
except Exception as e:
|
83 |
return str(e)
|
84 |
|
|
|
110 |
gr.Number(label="Adj Close"),
|
111 |
gr.Number(label="Volume")
|
112 |
],
|
113 |
+
outputs=[gr.Textbox(), gr.Image(type="pil")],
|
114 |
title="Stock Price Predictor",
|
115 |
description="Select the stock ticker and input the last recorded values to predict the closing price using the LSTM model."
|
116 |
)
|