Spaces:
Sleeping
Sleeping
akhfzl
commited on
Commit
·
fae0d0c
1
Parent(s):
569f076
'hf-models'
Browse files- __pycache__/utils.cpython-313.pyc +0 -0
- app.py +1 -0
- requirements.txt +1 -0
- utils.py +6 -19
__pycache__/utils.cpython-313.pyc
ADDED
|
Binary file (5.01 kB). View file
|
|
|
app.py
CHANGED
|
@@ -15,6 +15,7 @@ demo = gr.Interface(
|
|
| 15 |
"Masukkan nama dan harga mobil.\n\n"
|
| 16 |
"- Format **Nama Mobil**: '2024 Mitsubishi Pajero'\n"
|
| 17 |
"- Format **Harga**: 'Rp. 400.000.000 atau Rp 400.000'\n"
|
|
|
|
| 18 |
)
|
| 19 |
)
|
| 20 |
|
|
|
|
| 15 |
"Masukkan nama dan harga mobil.\n\n"
|
| 16 |
"- Format **Nama Mobil**: '2024 Mitsubishi Pajero'\n"
|
| 17 |
"- Format **Harga**: 'Rp. 400.000.000 atau Rp 400.000'\n"
|
| 18 |
+
"- Format **Tahun prediksi penjualan**: Jika kosong, default tahun saat ini\n"
|
| 19 |
)
|
| 20 |
)
|
| 21 |
|
requirements.txt
CHANGED
|
@@ -2,6 +2,7 @@ aiofiles==24.1.0
|
|
| 2 |
annotated-types==0.7.0
|
| 3 |
anyio==4.9.0
|
| 4 |
attrs==25.3.0
|
|
|
|
| 5 |
bleach==6.2.0
|
| 6 |
certifi==2025.4.26
|
| 7 |
cffi==1.17.1
|
|
|
|
| 2 |
annotated-types==0.7.0
|
| 3 |
anyio==4.9.0
|
| 4 |
attrs==25.3.0
|
| 5 |
+
audioop-lts==0.2.1
|
| 6 |
bleach==6.2.0
|
| 7 |
certifi==2025.4.26
|
| 8 |
cffi==1.17.1
|
utils.py
CHANGED
|
@@ -1,26 +1,13 @@
|
|
| 1 |
-
import re
|
| 2 |
import pandas as pd
|
| 3 |
-
import joblib
|
| 4 |
import numpy as np
|
| 5 |
-
from pathlib import Path
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
-
from
|
| 8 |
-
|
| 9 |
-
os.environ["KAGGLE_KEY"] = os.getenv("KAGGLE_KEY", "")
|
| 10 |
-
|
| 11 |
-
# Verify if variables exist
|
| 12 |
-
if not os.environ["KAGGLE_USERNAME"] or not os.environ["KAGGLE_KEY"]:
|
| 13 |
-
raise ValueError("KAGGLE_USERNAME or KAGGLE_KEY not set in environment!")
|
| 14 |
-
|
| 15 |
-
api = KaggleApi()
|
| 16 |
-
api.authenticate()
|
| 17 |
-
|
| 18 |
-
MODEL_PATH = "model.pkl"
|
| 19 |
-
if not os.path.exists(MODEL_PATH):
|
| 20 |
-
api.dataset_download_file("myfaizal/model", file_name="model.pkl", path=".", unzip=True)
|
| 21 |
-
|
| 22 |
|
| 23 |
bert_model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
|
|
| 24 |
|
| 25 |
def CarPricePrediction(car_names, car_prices, car_sold):
|
| 26 |
# inisialisasi
|
|
@@ -33,7 +20,7 @@ def CarPricePrediction(car_names, car_prices, car_sold):
|
|
| 33 |
|
| 34 |
names = car_names.strip()
|
| 35 |
prices = car_prices.strip()
|
| 36 |
-
car_sold = int(car_sold)
|
| 37 |
|
| 38 |
if not pattern.match(prices):
|
| 39 |
return 'Harga harus berformat rupiah misal: Rp. 2.000.000 atau Rp 2.000.000'
|
|
|
|
| 1 |
+
import re
|
| 2 |
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
import numpy as np
|
|
|
|
| 5 |
from sentence_transformers import SentenceTransformer
|
| 6 |
+
from huggingface_hub import hf_hub_download
|
| 7 |
+
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
bert_model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 10 |
+
MODEL_PATH = hf_hub_download(repo_id="akhfzl/legois-models", filename="model.pkl")
|
| 11 |
|
| 12 |
def CarPricePrediction(car_names, car_prices, car_sold):
|
| 13 |
# inisialisasi
|
|
|
|
| 20 |
|
| 21 |
names = car_names.strip()
|
| 22 |
prices = car_prices.strip()
|
| 23 |
+
car_sold = int(car_sold) if car_sold else datetime.now().year
|
| 24 |
|
| 25 |
if not pattern.match(prices):
|
| 26 |
return 'Harga harus berformat rupiah misal: Rp. 2.000.000 atau Rp 2.000.000'
|