Bhavy-227 commited on
Commit
15f2bf3
·
verified ·
1 Parent(s): 7044494

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +21 -0
  2. README.md +1 -2
  3. app.py +12 -2
  4. requirements.txt +1 -1
Dockerfile ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ build-essential \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ # Copy requirements and install
11
+ COPY requirements.txt .
12
+ RUN pip install --no-cache-dir -r requirements.txt
13
+
14
+ # Copy all project files
15
+ COPY . .
16
+
17
+ # Expose port
18
+ EXPOSE 7860
19
+
20
+ # Run app
21
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -3,8 +3,7 @@ title: Medical Report Analyzer
3
  emoji: 🏥
4
  colorFrom: blue
5
  colorTo: green
6
- sdk: gradio
7
- sdk_version: 4.44.0
8
  app_file: app.py
9
  pinned: true
10
  ---
 
3
  emoji: 🏥
4
  colorFrom: blue
5
  colorTo: green
6
+ sdk: docker
 
7
  app_file: app.py
8
  pinned: true
9
  ---
app.py CHANGED
@@ -276,6 +276,16 @@ def build_ui():
276
  # -----------------------------------------------
277
  if __name__ == "__main__":
278
  print("=== Medical Report Analyzer — Starting UI ===")
279
- print("Opening at: http://127.0.0.1:7860")
280
  app = build_ui()
281
- app.launch()
 
 
 
 
 
 
 
 
 
 
 
 
276
  # -----------------------------------------------
277
  if __name__ == "__main__":
278
  print("=== Medical Report Analyzer — Starting UI ===")
 
279
  app = build_ui()
280
+
281
+ # HuggingFace sets SPACE_ID env variable automatically
282
+ # Use it to detect deployment environment
283
+ import os
284
+ is_huggingface = os.getenv("SPACE_ID") is not None
285
+
286
+ if is_huggingface:
287
+ # HuggingFace Docker deployment
288
+ app.launch(server_name="0.0.0.0", server_port=7860)
289
+ else:
290
+ # Local development
291
+ app.launch(server_name="127.0.0.1", server_port=7861)
requirements.txt CHANGED
@@ -21,7 +21,7 @@ python-docx
21
  deep-translator
22
 
23
  # UI
24
- gradio==4.44.0
25
  # Data
26
  datasets
27
 
 
21
  deep-translator
22
 
23
  # UI
24
+ gradio
25
  # Data
26
  datasets
27