Ejemplo n.º 1
0
def submit_file():
    preds=random.randint(0,9)
    if request.method == 'POST':
        if 'file' not in request.files:
            flash('No file part')

            
            return redirect(request.url)
        file = request.files['file']
        if file.filename == '':
            flash('No file selected for uploading')
            return redirect(request.url)
        if file:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'],filename))
            getPrediction(filename)
            label= getPrediction(filename)
            print("Executeeeed/n\n")
            print(label)
            label=label
            pred=label.max()
            index=label.argmax()
            arr=['Safe driving', 
                'Texting - right', 
                'Talking on the phone - right', 
                'Texting - left', 
                'Talking on the phone - left', 
                'Operating the radio', 
                'Drinking', 
                'Reaching behind', 
                'Hair and makeup', 
                'Talking to passenger']
            result="Predicted as: "+ arr[preds]
            return result
def submit_file():
    if request.method == 'POST':
        if 'file' not in request.files:
            flash('No file part')
            return redirect(request.url)
        file = request.files['file']
        if file.filename == '':
            flash('No file selected for uploading')
            return redirect(request.url)
        if file:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            getPrediction(filename)
            label, acc = getPrediction(filename)
            flash(label)
            flash(acc)
            flash(filename)
            return redirect('/')
Ejemplo n.º 3
0
def submit_file():
    if request.method == 'POST':
        # if 'file' not in request.files:
        #     flash('No file part')
        #     return redirect(request.url)
        # file = request.files['file']
        # if file.filename == '':
        #     flash('No file selected for uploading')
        #     return redirect(request.url)
        # if file:
        filename = 'C:/Users/yoosh/PycharmProjects/pythonProject/imgUpdate/static/images/용구.jpg' #secure_filename(file.filename)
        #file.save(os.path.join(app.config['UPLOAD_FOLDER'],filename))
        getPrediction(filename)
        fabric, color, length = getPrediction(filename)
        flash(fabric)
        flash(color)
        flash(length)
        flash(filename)
        return redirect('/')
Ejemplo n.º 4
0
def submit_file_multi():
    labels = []
    if request.method == 'POST':
        files = request.files.getlist('multifile')
        print(files)
        for file in files:
            if file:
                filename = secure_filename(file.filename)
                file.save(os.path.join(UPLOAD_FOLDER, filename))
                label = getPrediction(filename)
                labels.append(label)
        return render_template("predictedmulti.html", labels=labels)
def submit_file():
    if request.method == 'POST':
        if 'file' not in request.files:
            flash('No file part')
            return redirect(request.url)
        file = request.files['file']
        if file.filename == '':
            flash('No file selected for uploading')
            return redirect(request.url)
        if file:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            getPrediction(filename)
            label, probabilities, reuse, orga, recy = getPrediction(filename)
            flash(label)
            flash(filename)
            flash("C:/Users/g/dti1/uploads/" + filename)
            flash(probabilities)
            flash(reuse)
            flash(orga)
            flash(recy)
            return redirect('/')
Ejemplo n.º 6
0
def submit_file():
    if request.method == 'POST':
        if 'file' not in request.files:
            flash('No file part')
            return redirect(request.url)
        file = request.files['file']
        if file.filename == '':
            flash('No file selected for uploading')
            return redirect(request.url)
        if file:
            filename = secure_filename(file.filename)
            file.save(os.path.join(UPLOAD_FOLDER, filename))
            label = getPrediction(filename)
            return render_template("predicted.html", label=label)
Ejemplo n.º 7
0
def submit_file():
    if request.method == 'POST':
        if 'file' not in request.files:
            flash('No file part')
            return redirect(request.url)
        file = request.files['file']
        if file.filename == '':
            flash('No file selected for uploading')
            return redirect(request.url)
        if file:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            label = getPrediction(filename)
            img_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
            print(img_path)
            return render_template('index.html',
                                   resultat=label,
                                   affich_image=url_for('static',
                                                        filename=filename))
Ejemplo n.º 8
0
 def test_get(self):
     self.assertEquals(getPrediction("Un.png"),"Tuberculosis")