Spaces:
Sleeping
Sleeping
import sys | |
sys.path.append("./src") | |
from kidney_classification.pipeline.prediction import PredictionPipeline | |
from kidney_classification.utils.common import decodeImage | |
from flask_cors import CORS, cross_origin | |
import os | |
from flask import Flask, request, jsonify, render_template | |
os.putenv("LANG", "en_US.UTF-8") | |
os.putenv("LC_ALL", "en_US.UTF-8") | |
app = Flask(__name__) | |
CORS(app) | |
class ClientApp: | |
def __init__(self): | |
self.filename = "inputImage.jpg" | |
self.classifier = PredictionPipeline(self.filename) | |
def home(): | |
return render_template("index.html") | |
def trainRoute(): | |
os.system("dvc repro") | |
return "Training done successfully!" | |
def predictRoute(): | |
image = request.json["image"] | |
decodeImage(image, clApp.filename) | |
result = clApp.classifier.predict() | |
return jsonify(result) | |
if __name__ == "__main__": | |
clApp = ClientApp() | |
app.run(host="0.0.0.0", port=7860) # for AWS | |