Example #1
0
from sqlalchemy.sql.expression import and_
from util.util import wsgi_print
from local_config import UPLOAD_DIR, LOG_FILE
from util.validator import StringValidator

app = Flask(__name__)


def init_db():
    from db import db

    db.create_all()


# dir config
app.config["upload_dir"] = os.path.join(os.getcwd(), UPLOAD_DIR)
app.config["samples_dir"] = os.path.join(os.getcwd(), "static/uploads")

# --- logs ---#

if not app.debug:
    import logging
    from logging import FileHandler

    file_handler = FileHandler(LOG_FILE)
    file_handler.setLevel(logging.WARNING)
    app.logger.addHandler(file_handler)


def init_app():
    """
Example #2
0
__MODEL = "random-forest.019.aw-d_wood-mask.100x100.1-even.grid.pkl"
__ROOT = os.path.abspath("../web")
app = Flask("timbr", static_folder=os.path.join(__ROOT, "static"), template_folder=os.path.join(__ROOT, "templates"))

upload_dir = os.path.join(__ROOT, "uploads")
if os.path.exists(upload_dir):
    shutil.rmtree(upload_dir)
os.mkdir(upload_dir)

start = time.time()
print("loading model")
_MODEL = TextureClassifier(os.path.join(__ROOT, "static/database"), __MODEL)
print("model loaded")
print("load time:", time.time() - start)

app.config["upload_dir"] = upload_dir
# ------------------------------------------------------------------------------


def save_histogram(source, destination, colorspace="rgb"):
    """
	saves rgb or hsv hostograms of source image to destination

	Args:
		source (str):
			fullpath of source image
		
		destination (str):
			fullpath of destination image

		colorspace opt(str):