text stringlengths 1 93.6k |
|---|
@app.route('/classify', methods=['POST'])
|
def classify():
|
try:
|
output_bytes = subprocess.check_output(['python', 'main.py'], stderr=subprocess.STDOUT)
|
output_str = output_bytes.decode('utf-8').strip()
|
class_name, image_path = output_str.split(",")
|
class_index = int(class_name)
|
cache.set('class_index', class_index)
|
cache.set('image_path', image_path)
|
return redirect(url_for('output', class_index=class_index))
|
except subprocess.CalledProcessError as e:
|
error_message = f"Error executing main.py: {e}"
|
return render_template('error.html', error_message=error_message)
|
@app.route('/output/<int:class_index>')
|
def output(class_index):
|
rendered_template = render_template('output.html', output=class_index)
|
return rendered_template
|
@app.route('/run_trans_app')
|
def run_trans_app():
|
class_index = cache.get('class_index')
|
image_path = cache.get('image_path')
|
class_index = int(class_index)
|
if class_index is not None and image_path is not None:
|
further_output = further_classifier(r"{}".format(image_path), class_index)
|
further_output_cleaned = further_output.strip()
|
return redirect(url_for('further_output_page', further_output=further_output_cleaned))
|
else:
|
return render_template('error.html', error_message="Cache is empty")
|
@app.route('/run_cap_app')
|
def run_cap_app():
|
class_index = cache.get('class_index')
|
image_path = cache.get('image_path')
|
class_index = int(class_index)
|
if class_index is not None and image_path is not None:
|
further_output = further_classifier(r"{}".format(image_path), class_index)
|
further_output_cleaned = further_output.strip()
|
return redirect(url_for('further_output_page', further_output=further_output_cleaned))
|
else:
|
return render_template('error.html', error_message="Cache is empty")
|
@app.route('/further_classf/<further_output>')
|
def further_output_page(further_output):
|
rendered_template = render_template('further.html', output=further_output)
|
return rendered_template
|
from flask import redirect, url_for
|
@app.route('/f_output', methods=['GET'])
|
def f_output():
|
component = request.args.get('component')
|
if component == 'cap':
|
return redirect(url_for('run_cap_app'))
|
elif component == 'trans':
|
return redirect(url_for('run_trans_app'))
|
else:
|
further_output = "Unknown component"
|
return render_template('further.html', output=further_output)
|
@app.route('/error')
|
def error():
|
error_message = "An error occurred. Please try again later."
|
return render_template('error.html', error_message=error_message)
|
if __name__ == '__main__':
|
app.run(host='localhost', debug=True, use_reloader=False)
|
# <FILESEP>
|
import argparse
|
import os
|
import sys
|
import gym
|
import torch
|
import torch.optim as optim
|
import torch.multiprocessing as mp
|
import torch.nn as nn
|
import torch.nn.functional as F
|
from model import Model, Shared_grad_buffers, Shared_obs_stats
|
from train import train
|
from test import test
|
from chief import chief
|
from utils import TrafficLight, Counter
|
class Params():
|
def __init__(self):
|
self.batch_size = 1000
|
self.lr = 3e-4
|
self.gamma = 0.99
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.