-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (25 loc) · 1.01 KB
/
app.py
File metadata and controls
30 lines (25 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import Flask, render_template, request, jsonify
from utils.logo_model_loader import load_model_tf, predict_image
from flask_cors import CORS
import os
# === Setup Flask ===
app = Flask(__name__, template_folder="templates", static_folder="static")
CORS(app)
# === Load ML Models ===
logo_model, brand_model = load_model_tf("models/authenticity_classifier_mobilenet.keras", "models/brand_classifier_mobilenet.keras")
static_path = 'static/Logos/'
# === Routes ===
@app.route('/', methods=['GET', 'POST'])
def home():
prediction = None
image_url = None
if request.method == 'POST':
image = request.files['image']
image_path = os.path.join(static_path, image.filename)
image.save(image_path)
image_url = '/static/Logos/' + image.filename
prediction = predict_image(logo_model, brand_model, image_path)
return render_template('fake_real_styles.html', image_url=image_url, prediction=prediction)
# === Run Server ===
if __name__ == '__main__':
app.run(debug=True)