예제 #1
0
파일: run.py 프로젝트: R-K-Sosa/Vaicam-Pai
import requests
import glob
from clarifai.rest import ClarifaiApp
import json

import os
app = ClarifaiApp('3sV5ZqH5HPz-obqWgk8m7iBHHf41IDhHHr_wUGaT', '91Mg1OCiSKYMemuJWt5GBWmK-FKmxOQ3DJmarLuY')

app = Flask(__name__)
app.config['DEBUG'] = True

@app.route("/")
def hello():
    wordbank = {}
    app = ClarifaiApp('UzbdCFxqhjb6JL94ogmugfWnfEKAJ7WGSeOe1GiQ', '_RkOzOu9L0ZTdVdIGKQcZKSuAnamobafUWZwpP8H')

    model = app.models.get('bc2c1be334f44095b8c214cdf2dc8fbe')

    newest = min(glob.iglob('*.png'), key=os.path.getctime)

    result = model.predict_by_filename(newest)

    # wordbank = (result.get("outputs")[0].get("data").get("concepts")[0].get("name")) + "         "+ str(result.get("outputs")[0].get("data").get("concepts")[0].get("value")) + "}"


    wordbank = (result.get("outputs")[0].get("data").get("concepts")[0])
    return jsonify(wordbank )

if __name__ == "__main__":
    app.run()
예제 #2
0
파일: parse.py 프로젝트: nwiegand1/HackNY

def parse(image):
    output = str(model.predict_by_url(url=image))
    index = output.find("u'name'") + 1
    concepts = []
    for i in range(1, output.count("u'name'")):
        index = output.find("u'name'", index + 1)
        concepts.append(output[index + 11:output.find("'", index + 13)])
    return concepts


print(parse(image))

from flask import Flask, render_template, request
app = Flask(__name__)


@app.route('/')
def index():
    return render_template('main.html')


@app.route('/send', methods=['POST'])
def send():
    response = parse(request.form["url"])
    return str(response)


app.run(debug=True)