rynfkn commited on
Commit
287a5c2
·
1 Parent(s): d4a131a

add configuration

Browse files
Files changed (2) hide show
  1. config.py +29 -0
  2. dockerfile +43 -0
config.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import torch
3
+
4
+ SCALER_PATH = 'model/scaler.pkl'
5
+ MODEL_PATH = 'model/best_model.pth'
6
+
7
+ TABULAR_DIM = 17
8
+ IMAGE_DIM = 1024
9
+ TEXT_DIM = 1024
10
+
11
+ IMAGE_MODEL_NAME = "facebook/dinov2-large"
12
+ TEXT_MODEL_NAME = "intfloat/multilingual-e5-large"
13
+
14
+ # DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
15
+ DEVICE = torch.device("cpu")
16
+
17
+ FEATURE_NAMES = ['Kamar Tidur', 'Kamar Mandi', 'Luas Tanah', 'Luas Bangunan',
18
+ 'Nama Perumahan', 'Sertifikat', 'Carpots', 'Daya Listrik',
19
+ 'Interior', 'Jumlah Lantai', 'Orientasi Bangunan',
20
+ 'Tahun Dibangun', 'Garasi', 'Latitude', 'Longitude', 'City',
21
+ 'District']
22
+
23
+ # Temp file storage
24
+ TEMP_IMAGE_PATH = "temp_image.jpg"
25
+
26
+ # Flask settings
27
+ DEBUG = os.environ.get('DEBUG', 'False') == 'True'
28
+ HOST = os.environ.get('HOST', '0.0.0.0')
29
+ PORT = int(os.environ.get('PORT', 5000))
dockerfile ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use official Python image as base
2
+ FROM python:3.12-slim
3
+
4
+ # Create a non-root user with UID 1000
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Setup ENV
8
+ ENV HOME=/home/user \
9
+ PATH=/home/user/.local/bin:$PATH
10
+
11
+ # Switch to the new user
12
+ USER user
13
+
14
+ # Set working directory
15
+ WORKDIR $HOME/app
16
+
17
+ # Upgrade pip while running as user
18
+ RUN pip install --user --no-cache-dir --upgrade pip
19
+
20
+ # Copy application files with correct ownership
21
+ COPY --chown=user requirements.txt $HOME/app/
22
+
23
+ # Install Python dependencies
24
+ RUN pip install --user --no-cache-dir -r requirements.txt
25
+
26
+ # Copy application files
27
+ COPY --chown=user app.py $HOME/app/
28
+ COPY --chown=user config.py $HOME/app/
29
+ COPY --chown=user inference $HOME/app/inference/
30
+ COPY --chown=user templates $HOME/app/templates/
31
+ COPY --chown=user static $HOME/app/static/
32
+
33
+ # Create temp directory for image uploads
34
+ RUN mkdir -p $HOME/app/temp
35
+
36
+ # Ensure correct PATH
37
+ ENV PATH="/home/user/.local/bin:$PATH"
38
+
39
+ # Expose Hugging Face Spaces default port (7860)
40
+ EXPOSE 7860
41
+
42
+ # Run Flask app with Gunicorn
43
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]