Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,8 +8,9 @@ import numpy as np
|
|
8 |
config = TimeSeriesTransformerConfig.from_pretrained("google/timesfm-2.0-500m-pytorch")
|
9 |
config.prediction_length = 3
|
10 |
config.context_length = 12
|
|
|
11 |
|
12 |
-
# Carregar modelo
|
13 |
model = TimeSeriesTransformerForPrediction.from_pretrained(
|
14 |
"google/timesfm-2.0-500m-pytorch",
|
15 |
config=config,
|
@@ -25,9 +26,9 @@ def prever_vendas(historico):
|
|
25 |
# Formatar dados
|
26 |
inputs = torch.tensor(historico).unsqueeze(0)
|
27 |
|
28 |
-
# Adicionar parâmetros
|
29 |
-
past_time_features = torch.zeros(1, config.context_length, 1) #
|
30 |
-
past_observed_mask = torch.ones(1, config.context_length) #
|
31 |
|
32 |
# Gerar previsão
|
33 |
with torch.no_grad():
|
@@ -48,7 +49,7 @@ iface = gr.Interface(
|
|
48 |
examples=[
|
49 |
["140,155,160,145,150,165,170,160,175,160,155,170"], # 12 meses
|
50 |
],
|
51 |
-
cache_examples=False # Desativar cache para evitar
|
52 |
)
|
53 |
|
54 |
iface.launch()
|
|
|
8 |
config = TimeSeriesTransformerConfig.from_pretrained("google/timesfm-2.0-500m-pytorch")
|
9 |
config.prediction_length = 3
|
10 |
config.context_length = 12
|
11 |
+
config.lags_sequence = [1, 2, 3, 4, 5, 6] # Ajuste os lags para serem menores que context_length
|
12 |
|
13 |
+
# Carregar modelo com a configuração ajustada
|
14 |
model = TimeSeriesTransformerForPrediction.from_pretrained(
|
15 |
"google/timesfm-2.0-500m-pytorch",
|
16 |
config=config,
|
|
|
26 |
# Formatar dados
|
27 |
inputs = torch.tensor(historico).unsqueeze(0)
|
28 |
|
29 |
+
# Adicionar parâmetros necessários
|
30 |
+
past_time_features = torch.zeros(1, config.context_length, 1) # Características temporais dummy
|
31 |
+
past_observed_mask = torch.ones(1, config.context_length) # Dados observados
|
32 |
|
33 |
# Gerar previsão
|
34 |
with torch.no_grad():
|
|
|
49 |
examples=[
|
50 |
["140,155,160,145,150,165,170,160,175,160,155,170"], # 12 meses
|
51 |
],
|
52 |
+
cache_examples=False # Desativar cache para evitar erros
|
53 |
)
|
54 |
|
55 |
iface.launch()
|