Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ dmypy.json

# Pyre type checker
.pyre/
.DS_Store
10 changes: 10 additions & 0 deletions add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Get user input for name and favorite sport
name = input("Adama Sall: ")
favorite_sport = input("Basketball: ")

# Display the collected information
print("\nHello,", name + "!")
print("Your favorite sport is:", favorite_sport)

# Wait for user to press Enter before closing
input("\nPress Enter to exit...")
19 changes: 19 additions & 0 deletions flask_ml_app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from flask import Flask, request, render_template
import joblib
import numpy as np

app = Flask(__name__)
model = joblib.load('model.joblib')

@app.route('/')
def home():
return render_template('index.html')

@app.route('/predict', methods=['POST'])
def predict():
features = [float(x) for x in request.form.values()]
prediction = model.predict([features])
return f"Predicted class: {prediction[0]}"

if __name__ == '__main__':
app.run(debug=True)
57 changes: 57 additions & 0 deletions flask_ml_app/create_pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.utils import ImageReader
import os

def create_pdf():
# Setup PDF
c = canvas.Canvas("deployment_documentation.pdf", pagesize=letter)
width, height = letter

# Add metadata
c.setTitle("Model Deployment Documentation")

# 1. Header Section
c.setFont("Helvetica-Bold", 16)
c.drawCentredString(width/2, height-50, "AI Model Deployment Report")

c.setFont("Helvetica", 12)
c.drawString(100, height-80, "Name: Adama")
c.drawString(100, height-100, "Batch Code: LISUM45")
c.drawString(100, height-120, "Submission Date: 2025-05-28")
c.drawString(100, height-140, "Submitted to: DAta Glacier intership week 4")

# 2. Add screenshots (ensure these files exist)
screenshot_dir = "screenshots"
screenshots = [
("1_model_training.png", "Step 1: Model Training Output"),
("2_flask_server.png", "Step 2: Flask Server Running"),
("3_web_interface.png", "Step 3: Web Application"),
("4_prediction.png", "Step 4: Prediction Result")
]

y_position = height-180
for i, (filename, description) in enumerate(screenshots):
if os.path.exists(f"{screenshot_dir}/{filename}"):
# Add description
c.drawString(100, y_position, description)
y_position -= 20

# Add image (scaled to 400px width)
img = ImageReader(f"{screenshot_dir}/{filename}")
img_width = 400
img_height = img._image.size[1] * (img_width/img._image.size[0])
c.drawImage(img, 100, y_position-img_height, width=img_width, height=img_height)
y_position -= img_height + 40

# Add new page if needed
if y_position < 100 and i < len(screenshots)-1:
c.showPage()
y_position = height-50

# Save PDF
c.save()
print("PDF successfully generated!")

if __name__ == "__main__":
create_pdf()
Binary file added flask_ml_app/deployment_documentation.pdf
Binary file not shown.
Binary file added flask_ml_app/model.joblib
Binary file not shown.
Binary file added flask_ml_app/screenshots/1_model_training.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flask_ml_app/screenshots/2_flask_server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flask_ml_app/screenshots/3_web_interface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flask_ml_app/screenshots/4_prediction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions flask_ml_app/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<body>
<h2>Iris Classifier</h2>
<form action="/predict" method="post">
Sepal Length: <input type="text" name="sepal_length"><br>
Sepal Width: <input type="text" name="sepal_width"><br>
Petal Length: <input type="text" name="petal_length"><br>
Petal Width: <input type="text" name="petal_width"><br>
<input type="submit" value="Predict">
</form>
</body>
</html>
15 changes: 15 additions & 0 deletions flask_ml_app/train.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
import joblib
import pandas as pd

# Step 1: Load toy data
iris = load_iris()
X, y = iris.data, iris.target

# Step 2: Train and save model
model = RandomForestClassifier()
model.fit(X, y)
joblib.dump(model, 'model.joblib')

print("Model trained and saved!")
Loading