TheBug95 commited on
Commit
372d5c5
·
1 Parent(s): 1f7c87f

cambios realizados para despligue con docker en Huggingface

Browse files
.dockerignore ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Git
2
+ .git
3
+ .gitattributes
4
+ .gitignore
5
+
6
+ # Python
7
+ __pycache__
8
+ *.pyc
9
+ *.pyo
10
+ *.egg-info
11
+ .venv
12
+ venv
13
+ env
14
+
15
+ # IDE
16
+ .vscode
17
+ .idea
18
+ *.swp
19
+ *.swo
20
+
21
+ # Local databases (fresh on each deploy)
22
+ *.db
23
+
24
+ # Jupyter
25
+ *.ipynb
26
+ .ipynb_checkpoints
27
+
28
+ # Misc
29
+ *.log
30
+ *.csv
31
+ *.zip
32
+ .env
33
+ .env.*
34
+ packages.txt
35
+ LICENSE
36
+ README.md
.streamlit/config.toml CHANGED
@@ -1,9 +1,10 @@
1
  [server]
2
  headless = true
3
- port = 8501
 
4
  enableCORS = false
 
5
  maxUploadSize = 50
6
- enableXsrfProtection = true
7
 
8
  [browser]
9
  gatherUsageStats = false
 
1
  [server]
2
  headless = true
3
+ port = 7860
4
+ address = "0.0.0.0"
5
  enableCORS = false
6
+ enableXsrfProtection = false
7
  maxUploadSize = 50
 
8
 
9
  [browser]
10
  gatherUsageStats = false
Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ── OphthalmoCapture – Hugging Face Spaces (Docker + Streamlit) ──────────────
2
+ FROM python:3.10-slim
3
+
4
+ # ── System dependencies ──────────────────────────────────────────────────────
5
+ RUN apt-get update && apt-get install -y --no-install-recommends \
6
+ ffmpeg \
7
+ build-essential \
8
+ git \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ # ── Non-root user (HF Spaces requirement) ───────────────────────────────────
12
+ RUN useradd -m -u 1000 user
13
+ ENV HOME=/home/user \
14
+ PATH=/home/user/.local/bin:$PATH
15
+
16
+ WORKDIR $HOME/app
17
+
18
+ # ── Python dependencies ──────────────────────────────────────────────────────
19
+ COPY --chown=user requirements.txt .
20
+ USER user
21
+ RUN pip install --no-cache-dir --upgrade pip && \
22
+ pip install --no-cache-dir -r requirements.txt
23
+
24
+ # ── Pre-download Whisper model (base.en) to bake into image ─────────────────
25
+ # This avoids a ~150 MB download on every cold start.
26
+ # Change to "small" / "medium" if you upgrade hardware.
27
+ RUN python -c "import whisper; whisper.load_model('base.en')"
28
+
29
+ # ── Copy application code ───────────────────────────────────────────────────
30
+ COPY --chown=user . .
31
+
32
+ # ── Streamlit configuration ─────────────────────────────────────────────────
33
+ # HF Spaces expects port 7860
34
+ EXPOSE 7860
35
+
36
+ HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1
37
+
38
+ # ── Launch ───────────────────────────────────────────────────────────────────
39
+ ENTRYPOINT ["streamlit", "run", "interface/main.py", \
40
+ "--server.port=7860", \
41
+ "--server.address=0.0.0.0", \
42
+ "--server.enableCORS=false", \
43
+ "--server.enableXsrfProtection=false", \
44
+ "--browser.gatherUsageStats=false"]
interface/dataset_fl.csv DELETED
The diff for this file is too large to render. See raw diff
 
interface/services/whisper_service.py CHANGED
@@ -16,9 +16,10 @@ if shutil.which("ffmpeg") is None:
16
  try:
17
  import imageio_ffmpeg
18
  _ffmpeg_real = imageio_ffmpeg.get_ffmpeg_exe()
19
- # The bundled binary has a long name; create an alias as ffmpeg.exe
20
- # next to it so that Whisper (which calls "ffmpeg") can find it.
21
- _ffmpeg_alias = os.path.join(os.path.dirname(_ffmpeg_real), "ffmpeg.exe")
 
22
  if not os.path.exists(_ffmpeg_alias):
23
  try:
24
  os.link(_ffmpeg_real, _ffmpeg_alias) # hard link (no admin)
@@ -26,7 +27,7 @@ if shutil.which("ffmpeg") is None:
26
  import shutil as _sh
27
  _sh.copy2(_ffmpeg_real, _ffmpeg_alias) # fallback: copy
28
  os.environ["PATH"] = (
29
- os.path.dirname(_ffmpeg_alias) + os.pathsep + os.environ.get("PATH", "")
30
  )
31
  except ImportError:
32
  pass # Will fail later with a clear Whisper error
 
16
  try:
17
  import imageio_ffmpeg
18
  _ffmpeg_real = imageio_ffmpeg.get_ffmpeg_exe()
19
+ _ffmpeg_dir = os.path.dirname(_ffmpeg_real)
20
+ # Create an alias so that Whisper (which calls "ffmpeg") can find it.
21
+ _alias_name = "ffmpeg.exe" if os.name == "nt" else "ffmpeg"
22
+ _ffmpeg_alias = os.path.join(_ffmpeg_dir, _alias_name)
23
  if not os.path.exists(_ffmpeg_alias):
24
  try:
25
  os.link(_ffmpeg_real, _ffmpeg_alias) # hard link (no admin)
 
27
  import shutil as _sh
28
  _sh.copy2(_ffmpeg_real, _ffmpeg_alias) # fallback: copy
29
  os.environ["PATH"] = (
30
+ _ffmpeg_dir + os.pathsep + os.environ.get("PATH", "")
31
  )
32
  except ImportError:
33
  pass # Will fail later with a clear Whisper error
requirements.txt CHANGED
@@ -1,12 +1,9 @@
1
- streamlit
2
  openai-whisper
3
  imageio-ffmpeg
4
  torch
5
  pandas
6
- firebase-admin
7
- notebook
8
- transformers
9
  pillow
10
- whisper
11
  numba
12
- streamlit-authenticator
 
 
1
+ streamlit>=1.54.0
2
  openai-whisper
3
  imageio-ffmpeg
4
  torch
5
  pandas
 
 
 
6
  pillow
 
7
  numba
8
+ streamlit-authenticator
9
+ bcrypt
results_marisse.csv DELETED
The diff for this file is too large to render. See raw diff