Spaces:
Sleeping
Sleeping
update app
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import yfinance as yf
|
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
import torch
|
| 6 |
-
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 7 |
from datetime import datetime, timedelta
|
| 8 |
import plotly.graph_objects as go
|
| 9 |
import plotly.express as px
|
|
@@ -30,19 +30,18 @@ from config import IDX_STOCKS, TECHNICAL_INDICATORS, PREDICTION_CONFIG
|
|
| 30 |
@spaces.GPU(duration=120)
|
| 31 |
def load_model():
|
| 32 |
"""Load the Amazon Chronos-Bolt model for time series forecasting"""
|
| 33 |
-
#
|
| 34 |
model = AutoModelForSeq2SeqLM.from_pretrained(
|
| 35 |
"amazon/chronos-bolt-base",
|
| 36 |
torch_dtype=torch.bfloat16,
|
| 37 |
device_map="auto",
|
| 38 |
trust_remote_code=True
|
| 39 |
)
|
| 40 |
-
#
|
| 41 |
-
# This
|
| 42 |
-
tokenizer =
|
| 43 |
"amazon/chronos-bolt-base",
|
| 44 |
-
trust_remote_code=True
|
| 45 |
-
use_fast=False
|
| 46 |
)
|
| 47 |
return model, tokenizer
|
| 48 |
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
import torch
|
| 6 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 7 |
from datetime import datetime, timedelta
|
| 8 |
import plotly.graph_objects as go
|
| 9 |
import plotly.express as px
|
|
|
|
| 30 |
@spaces.GPU(duration=120)
|
| 31 |
def load_model():
|
| 32 |
"""Load the Amazon Chronos-Bolt model for time series forecasting"""
|
| 33 |
+
# Fix: Use AutoModelForSeq2SeqLM and trust_remote_code=True for the T5-based model
|
| 34 |
model = AutoModelForSeq2SeqLM.from_pretrained(
|
| 35 |
"amazon/chronos-bolt-base",
|
| 36 |
torch_dtype=torch.bfloat16,
|
| 37 |
device_map="auto",
|
| 38 |
trust_remote_code=True
|
| 39 |
)
|
| 40 |
+
# Fix: Reverting to AutoTokenizer with ONLY trust_remote_code=True
|
| 41 |
+
# This should correctly invoke the custom ChronosTokenizer class and resolve model files.
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 43 |
"amazon/chronos-bolt-base",
|
| 44 |
+
trust_remote_code=True
|
|
|
|
| 45 |
)
|
| 46 |
return model, tokenizer
|
| 47 |
|