Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def message(): | |
| return "🚧 Under Construction 🚧\n\nCheck back soon!" | |
| demo = gr.Interface( | |
| fn=message, | |
| inputs=[], | |
| outputs=gr.Textbox(label="Status"), | |
| title="Site Under Construction", | |
| description="This application is currently being updated. Please check back later!" | |
| ) | |
| demo.launch() | |
| # import gradio as gr | |
| # import numpy as np | |
| # import pandas as pd | |
| # import tensorflow as tf | |
| # import joblib | |
| # from tensorflow.keras.models import load_model | |
| # # Load the trained LSTM model | |
| # model = load_model("lstm_gru_model5.h5") | |
| # # Load the MinMaxScaler | |
| # scaler = joblib.load("forex_scaler222.pkl") | |
| # def preprocess_input(data): | |
| # """Preprocess input data for LSTM model.""" | |
| # if len(data) < 60: | |
| # mean_value = np.mean(data) # Compute mean of given prices | |
| # data = data + [mean_value] * (60 - len(data)) # Fill missing spots | |
| # data = np.array(data).reshape(1, -1) # Reshape for MinMaxScaler | |
| # scaled_data = scaler.transform(data) # Scale the input | |
| # return scaled_data.reshape(1, 60, 1) # Reshape for LSTM | |
| # def predict_forex(prices): | |
| # """Predict the next forex price based on the input sequence.""" | |
| # try: | |
| # input_data = [float(price) for price in prices.split(",")] | |
| # # Ensure enough input data | |
| # if len(input_data) < 60: | |
| # return "Please provide at least 60 previous forex prices." | |
| # # Use last 60 prices | |
| # preprocessed_data = preprocess_input(input_data[-60:]) | |
| # prediction = model.predict(preprocessed_data) | |
| # # Convert back to original scale | |
| # predicted_price = scaler.inverse_transform(prediction)[0][0] | |
| # return f"Predicted Next Price: {predicted_price:.5f}" | |
| # except Exception as e: | |
| # return f"Error: {str(e)}" | |
| # def batch_predict(file): | |
| # """Batch prediction for CSV files.""" | |
| # try: | |
| # df = pd.read_csv(file) | |
| # if "prices" not in df.columns: | |
| # return "CSV must have a 'prices' column with historical data." | |
| # df["predictions"] = df["prices"].rolling(window=10).apply(lambda x: predict_forex(",".join(map(str, x))) if len(x) == 10 else None) | |
| # return df.dropna() | |
| # except Exception as e: | |
| # return f"Error: {str(e)}" | |
| # # Gradio UI | |
| # demo = gr.Interface( | |
| # fn=predict_forex, | |
| # inputs=gr.Textbox(label="Enter last 10 forex prices (comma-separated)"), | |
| # outputs=gr.Textbox(label="Predicted Next Price"), | |
| # title="Forex Price Predictor", | |
| # description="Enter the last 10 forex prices to predict the next price. Upload CSV for batch predictions.", | |
| # examples=[ | |
| # ["1.2345,1.2350,1.2360,1.2370,1.2380,1.2390,1.2400,1.2410,1.2420,1.2430"] | |
| # ], | |
| # allow_flagging="never" | |
| # ) | |
| # batch_demo = gr.Interface( | |
| # fn=batch_predict, | |
| # inputs=gr.File(label="Upload CSV"), | |
| # outputs=gr.Dataframe(label="Predictions"), | |
| # title="Batch Prediction", | |
| # description="Upload a CSV with a 'prices' column for batch predictions." | |
| # ) | |
| # gr.TabbedInterface([demo, batch_demo], ["Single Prediction", "Batch Prediction"]).launch() | |