def get_prediction(self, type, img_full_path=None, img_path=None, showbboxUI=None): error_message = '' config = Common_config() predictMode = PredictMode.classifyOnly #if(classify_detect): #predictMode = PredictMode.classifyAndDetect data = None if (type == PredictType.sampleImages): data, img_path, has_error = self.get_prediction_sampleImg( img_path, img_full_path, predictMode) if (type == PredictType.uploadedFile): data, img_path, has_error, error_message = self.get_prediction_uploadedFile( img_path, img_full_path, predictMode) #if(type == PredictType.fromURL): #data, img_path, has_error = self.get_prediction_url(predictMode) return data, img_path, has_error, error_message
import sys import uuid import common import requests import traceback import numpy as np from PIL import Image from search import Search from urllib.parse import urlparse from io import StringIO from enums import * from common import * from common_config import Common_config from flask import Flask, render_template, request, jsonify, make_response, url_for, g config = Common_config() root_direc = config.get_root_path() sample_direc = config.get_sample_img_path() upload_direc = config.get_upload_path() model_path = config.get_model_path() max_file_size = 3750000 def str2bool(v): return v.lower() in ("yes", "true", "t", "1") def delete_all_uploaded(): directory = "." + upload_direc
import os import future import random import pandas as pd from common_config import Common_config config = Common_config() root_direc = config.get_root_path() class Sample_images: def __init__(self): self.list = self.shuffle_animal_list() self.start_range = 0 def shuffle_animal_list(self): d = pd.read_csv(root_direc + "/static/data/updated_animal_list.csv") print(d) d = d.sample(frac=1) return d def get_images_data(self, add_more): end_range = self.start_range + 8 if(not add_more): end_range = self.start_range + 12 img_list = []
from PIL import Image from search import Search from flask import json from enums import * from common import * from io import StringIO from flask import send_file from predict import Predict from common_config import Common_config from sample_images import Sample_images s = Search() predict = Predict() sample_images = Sample_images() config = Common_config() root_direc = config.get_root_path() show_bbox = config.show_bbox() from flask import Flask, render_template, request, jsonify, make_response, url_for, g app = Flask(__name__, static_url_path="/static", static_folder="static") @app.route('/') @app.route('/index.html') def index(): try: return render_template('/explore.html') except Exception as e: var = traceback.format_exc()
import numpy as np from PIL import Image from bbox import Bbox from flask import request from search import Search from io import StringIO from flask import send_file from enums import * from common import * from urllib.parse import urlparse from common_config import Common_config from common import str2bool, delete_all_uploaded import Predict_Trees from keras.preprocessing.image import load_img config = Common_config() root_direc = config.get_root_path() sample_direc = config.get_sample_img_path() upload_direc = config.get_upload_path() bbox = Bbox() '''Move this to config file ''' CONTENT_TYPE_KEY = "Content-Type" CONTENT_TYPE = 'application/octet-stream' SUBSCRIPTION_KEY = '<add subscription key here> ' AUTHORIZATION_HEADER = 'Ocp-Apim-Subscription-Key' base_url = '<add AI for earth API base URL here>' classify_format = '{0}/species-recognition/v{1}/predict?topK={2}&predictMode={3}'