Omarelrayes commited on
Commit
f9781d4
·
verified ·
1 Parent(s): f05d6e9

Upload 5 files

Browse files
Files changed (5) hide show
  1. .gitattributes +8 -35
  2. .gitignore +11 -17
  3. Dockerfile +2 -9
  4. README.md +36 -6
  5. requirements.txt +10 -8
.gitattributes CHANGED
@@ -1,35 +1,8 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ *.py text eol=lf
2
+ *.md text eol=lf
3
+ *.txt text eol=lf
4
+ *.yml text eol=lf
5
+ *.yaml text eol=lf
6
+ *.json text eol=lf
7
+ Dockerfile text eol=lf
8
+ .gitignore text eol=lf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore CHANGED
@@ -1,20 +1,14 @@
1
- # environment
2
  venv/
3
- .venv/
4
-
5
- # ML / MLflow
6
- mlflow/
7
- mlartifacts/
8
- *.keras
9
- *.h5
10
- *.pkl
11
-
12
-
13
-
14
- # Python cache
15
  __pycache__/
16
  *.pyc
17
-
18
- # IDE
19
- .vscode/
20
- .idea/
 
 
 
 
 
 
 
 
 
1
  venv/
 
 
 
 
 
 
 
 
 
 
 
 
2
  __pycache__/
3
  *.pyc
4
+ .DS_Store
5
+ storage/images/*
6
+ storage/segments/*
7
+ storage/results/*
8
+ !storage/images/.gitkeep
9
+ !storage/segments/.gitkeep
10
+ !storage/results/.gitkeep
11
+ models/
12
+ *.h5
13
+ *.keras
14
+ .env
Dockerfile CHANGED
@@ -1,19 +1,12 @@
1
- FROM python:3.10
2
 
3
  WORKDIR /app
4
- #
5
- # 🔥 Set PYTHONPATH to include root directory (for sitecustomize.py)
6
- ENV PYTHONPATH=/app:${PYTHONPATH}
7
 
8
- # install dependencies
9
  COPY requirements.txt .
10
  RUN pip install --no-cache-dir -r requirements.txt
11
 
12
- # copy project files
13
  COPY . .
14
 
15
- # expose port (Hugging Face uses 7860)
16
  EXPOSE 7860
17
 
18
- # run app
19
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM python:3.11-slim
2
 
3
  WORKDIR /app
 
 
 
4
 
 
5
  COPY requirements.txt .
6
  RUN pip install --no-cache-dir -r requirements.txt
7
 
 
8
  COPY . .
9
 
 
10
  EXPOSE 7860
11
 
12
+ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
README.md CHANGED
@@ -1,12 +1,42 @@
1
  ---
2
- title: Api
3
- emoji: 🏆
4
- colorFrom: yellow
5
- colorTo: pink
6
  sdk: docker
7
  pinned: false
8
  license: mit
9
- short_description: fast api for models
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Skin Cancer Detection API
3
+ emoji: 🏥
4
+ colorFrom: blue
5
+ colorTo: red
6
  sdk: docker
7
  pinned: false
8
  license: mit
9
+ short_description: FastAPI for skin cancer classification & segmentation
10
  ---
11
 
12
+ # Skin Cancer Detection API
13
+
14
+ FastAPI application for skin cancer classification and segmentation, deployed on Hugging Face Spaces.
15
+
16
+ ## API Endpoints
17
+
18
+ | Method | Endpoint | Description |
19
+ |---|---|---|
20
+ | GET | `/` | Service root — model status & info |
21
+ | GET | `/health` | Health check — service & model availability |
22
+ | GET | `/metrics` | Prometheus metrics endpoint |
23
+ | GET | `/models/status` | Detailed model load status |
24
+ | GET | `/api/ab-status` | A/B testing configuration status |
25
+ | POST | `/api/upload` | Upload an image, returns `image_id` |
26
+ | POST | `/api/classify` | Classify by `image_id` |
27
+ | GET | `/api/classify/{image_id}` | Get stored classification result |
28
+ | POST | `/api/segment` | Segment by `image_id` |
29
+ | GET | `/api/segment/{image_id}` | Get stored segmentation result |
30
+ | GET | `/api/images/{image_id}` | Retrieve uploaded image |
31
+
32
+ ## Environment Variables
33
+
34
+ | Variable | Default | Description |
35
+ |---|---|---|
36
+ | `HF_TOKEN` | - | Hugging Face token for model downloads |
37
+ | `HF_MODEL_REPO` | `omarelrayes/mlflow-artifacts` | HF repo with model zips |
38
+ | `CLASSIFIER_MODEL_PATH` | `models/classifier_savedmodel.zip` | Path in HF repo |
39
+ | `SEGMENTER_MODEL_PATH` | `models/segmenter_savedmodel.zip` | Path in HF repo |
40
+ | `CLASSIFIER_THRESHOLD` | `0.5` | Confidence threshold |
41
+ | `AB_TESTING_ENABLED` | `false` | Enable A/B testing |
42
+ | `AB_CLASSIFIER_B` | - | Alternative model URI |
requirements.txt CHANGED
@@ -1,8 +1,10 @@
1
- fastapi
2
- uvicorn
3
- tensorflow>=2.18.0
4
- mlflow
5
- huggingface_hub
6
- python-multipart
7
- pillow
8
- numpy
 
 
 
1
+ fastapi>=0.104.0
2
+ uvicorn[standard]>=0.24.0
3
+ python-multipart>=0.0.6
4
+ Pillow>=10.1.0
5
+ numpy>=1.24.3
6
+ pydantic>=2.5.0
7
+ tensorflow-cpu>=2.13.0
8
+ prometheus-client>=0.19.0
9
+ huggingface-hub>=0.20.0
10
+ starlette>=0.27.0