ALYYAN commited on
Commit
80019a3
·
1 Parent(s): 89a4662

improvements added

Browse files
Files changed (3) hide show
  1. app.py +5 -1
  2. dockerfile +1 -0
  3. src/cnnClassifier/__init__.py +4 -11
app.py CHANGED
@@ -6,7 +6,11 @@ from fastapi.staticfiles import StaticFiles
6
  from fastapi.templating import Jinja2Templates
7
  from fastapi.middleware.cors import CORSMiddleware
8
  from pydantic import BaseModel
9
- import uvicorn # For running the app directly if needed
 
 
 
 
10
 
11
  # Your existing ML components
12
  from cnnClassifier.utils.common import decodeImage
 
6
  from fastapi.templating import Jinja2Templates
7
  from fastapi.middleware.cors import CORSMiddleware
8
  from pydantic import BaseModel
9
+ import uvicorn
10
+ import sys # <-- Add this import
11
+ from pathlib import Path # <-- Add this import
12
+
13
+ sys.path.append(str(Path(__file__).parent / "src"))
14
 
15
  # Your existing ML components
16
  from cnnClassifier.utils.common import decodeImage
dockerfile CHANGED
@@ -15,6 +15,7 @@ RUN pip install --no-cache-dir -r requirements.txt
15
  COPY app.py .
16
  COPY static ./static
17
  COPY templates ./templates
 
18
  # We need the model, which should be tracked by Git LFS.
19
  # Create a model directory in the container and copy the model into it.
20
  RUN mkdir model
 
15
  COPY app.py .
16
  COPY static ./static
17
  COPY templates ./templates
18
+ COPY src/ .
19
  # We need the model, which should be tracked by Git LFS.
20
  # Create a model directory in the container and copy the model into it.
21
  RUN mkdir model
src/cnnClassifier/__init__.py CHANGED
@@ -1,21 +1,14 @@
1
- import os
2
  import sys
3
  import logging
4
 
 
5
  logging_str = "[%(asctime)s: %(levelname)s: %(module)s: %(message)s]"
6
 
7
- log_dir = "logs"
8
- log_filepath = os.path.join(log_dir,"running_logs.log")
9
- os.makedirs(log_dir, exist_ok=True)
10
-
11
-
12
  logging.basicConfig(
13
- level= logging.INFO,
14
- format= logging_str,
15
-
16
  handlers=[
17
- logging.FileHandler(log_filepath),
18
- logging.StreamHandler(sys.stdout)
19
  ]
20
  )
21
 
 
 
1
  import sys
2
  import logging
3
 
4
+ # We will log directly to the console (stdout), which Hugging Face captures.
5
  logging_str = "[%(asctime)s: %(levelname)s: %(module)s: %(message)s]"
6
 
 
 
 
 
 
7
  logging.basicConfig(
8
+ level=logging.INFO,
9
+ format=logging_str,
 
10
  handlers=[
11
+ logging.StreamHandler(sys.stdout) # Only log to the console
 
12
  ]
13
  )
14