forked from s434650/CatOrNot
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2b44aee238 | ||
21e04c9f18 | |||
|
9a1659292c | ||
f1ad502f13 | |||
04df0bed03 | |||
b7c8a2f4d1 | |||
9c9a9ce770 | |||
|
2e8abef8a5 | ||
|
83134656a9 | ||
fdb66a042b | |||
|
8cfa2f85ae | ||
db7e5971f7 |
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# Cat or Not - artifact repository
|
||||
# First prototype
|
||||
### Monday 15:30 group
|
||||
|
||||
## How to use this repository?
|
||||
To send an artifact for evaluation, create a pull request with it. Accepted artifacts will be merged into repository.
|
||||
|
||||
In case of an artifact not passing a quality control, person responsible will be contacted with informations about necessary changes.
|
||||
|
||||
Documentation is located in the **docs** branch.
|
||||
|
||||
Application prototype is located in the **app** branch.
|
||||
|
||||
## Version Control Document
|
||||
It is located in a [repository's wiki](https://git.wmi.amu.edu.pl/s434650/CatOrNot/wiki/Version+History+Document). It will be updated with each accepted artifact.
|
||||
|
||||
## Heroku application
|
||||
https://lit-wildwood-10245.herokuapp.com/
|
BIN
Test Plan(2).pdf
BIN
Test Plan(2).pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,7 +0,0 @@
|
||||
from flask import Flask
|
||||
from config import Config
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(Config)
|
||||
|
||||
from app import routes
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,20 +0,0 @@
|
||||
# Imports the Google Cloud client library
|
||||
from google.cloud import vision
|
||||
from google.cloud.vision import types
|
||||
|
||||
def is_cat(content):
|
||||
labels = fetch_data(content)
|
||||
if labels[0].description == "cat":
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def fetch_data(content):
|
||||
# Instantiates a client
|
||||
client = vision.ImageAnnotatorClient()
|
||||
# Tell Google Vision that our content is of type Image
|
||||
image = types.Image(content=content)
|
||||
# Performs label detection on the image file
|
||||
response = client.label_detection(image=image)
|
||||
# Return array of labels
|
||||
return response.label_annotations
|
@ -1,7 +0,0 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, PasswordField, BooleanField, SubmitField
|
||||
from wtforms.validators import DataRequired
|
||||
|
||||
class UploadForm(FlaskForm):
|
||||
url = StringField('Link', validators=[DataRequired()])
|
||||
submit = SubmitField('Cat or not?')
|
@ -1,10 +0,0 @@
|
||||
import requests
|
||||
|
||||
def get_image_from_url(url):
|
||||
f = open('pic.jpg','wb')
|
||||
f.write(requests.get(url).content)
|
||||
f.close()
|
||||
f = open('pic.jpg','rb')
|
||||
file = f.read()
|
||||
f.close()
|
||||
return file
|
@ -1,18 +0,0 @@
|
||||
from flask import Flask
|
||||
from flask import render_template
|
||||
from app.forms import UploadForm
|
||||
from app import app
|
||||
from app import cat_recognition as cat
|
||||
from app import picture_downloader as downloader
|
||||
|
||||
@app.route('/', methods=['GET', 'POST'])
|
||||
def index():
|
||||
form = UploadForm()
|
||||
if form.validate_on_submit():
|
||||
content = downloader.get_image_from_url(form.url.data)
|
||||
if cat.is_cat(content):
|
||||
return "Cat!"
|
||||
else:
|
||||
return "Not!"
|
||||
|
||||
return render_template('index.html', form=form)
|
@ -1,23 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
{% if title %}
|
||||
<title>{{ title }} | Cat or Not</title>
|
||||
{% else %}
|
||||
<title>Cat or Not</title>
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
@ -1,13 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Check if the picture is cat or not!</h1>
|
||||
<form action="" method="post" novalidate>
|
||||
{{ form.hidden_tag() }}
|
||||
<p>
|
||||
{{ form.url.label }}<br>
|
||||
{{ form.url }}
|
||||
</p>
|
||||
<p>{{ form.submit() }}</p>
|
||||
</form>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user