varunkuntal commited on
Commit
dc71762
1 Parent(s): 60eee60
Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python image from the Docker Hub
2
+ FROM python:3.9
3
+
4
+ # Set the working directory to /code
5
+ WORKDIR /code
6
+
7
+ # Copy requirements.txt to the docker container
8
+ COPY ./requirements.txt /code/requirements.txt
9
+
10
+ # Install any dependencies
11
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
+
13
+ # Copy the current directory contents into the container at /code
14
+ COPY . .
15
+
16
+ # Run the command to start Uvicorn
17
+ CMD ["uvicorn", "app.app:app", "--host", "0.0.0.0", "--port", "7860"]
app/__pycache__/app.cpython-39.pyc ADDED
Binary file (760 Bytes). View file
 
app/app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ from joblib import load
4
+ import pickle
5
+
6
+ app = FastAPI()
7
+
8
+ with open('gs_clf.pickle', 'rb') as f:
9
+ spam_classifier = pickle.load(f)
10
+
11
+ class Item(BaseModel):
12
+ text: str
13
+
14
+ @app.post("/classify/")
15
+ async def classify_text(item: Item):
16
+ return {"result": spam_classifier.predict([item.text])[0]}
gs_clf.pickle ADDED
Binary file (942 kB). View file
 
gs_clf.pickle:Zone.Identifier ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [ZoneTransfer]
2
+ ZoneId=3
3
+ HostUrl=about:internet
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ fastapi
2
+ uvicorn
3
+ scikit-learn
4
+
static/style.css ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ color: #333;
4
+ background-color: #f9f9f9;
5
+ padding: 30px;
6
+ }
7
+
8
+ .container {
9
+ display: flex;
10
+ flex-direction: column;
11
+ align-items: center;
12
+ justify-content: center;
13
+ height: 100vh;
14
+ text-align: center;
15
+ }
16
+
17
+ textarea, button {
18
+ width: 300px;
19
+ margin-bottom: 20px;
20
+ padding: 10px;
21
+ font-size: 1em;
22
+ border: none;
23
+ border-radius: 5px;
24
+ }
25
+
26
+ textarea {
27
+ height: 100px;
28
+ resize: none;
29
+ }
30
+
31
+ button {
32
+ color: #fff;
33
+ background-color: #007BFF;
34
+ cursor: pointer;
35
+ transition: background-color 0.3s ease;
36
+ }
37
+
38
+ button:hover {
39
+ background-color: #0056b3;
40
+ }
41
+
42
+ .result {
43
+ font-size: 1.5em;
44
+ }
templates/index.html ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Spam Classifier App</title>
6
+ <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
7
+ </head>
8
+ <body>
9
+ <div class="container">
10
+ <h1>Spam Classifier</h1>
11
+ <form method="POST">
12
+ <textarea name="message" required></textarea>
13
+ <button type="submit">Classify</button>
14
+ </form>
15
+ {% if prediction %}
16
+ <div class="result">Classification Result: {{ prediction }}</div>
17
+ {% endif %}
18
+ </div>
19
+ </body>
20
+ </html>