some changes
Browse files- .gitignore +52 -0
- app.py +30 -11
- requirements.txt +1 -2
.gitignore
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# These are some examples of commonly ignored file patterns.
|
| 2 |
+
# You should customize this list as applicable to your project.
|
| 3 |
+
# Learn more about .gitignore:
|
| 4 |
+
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
|
| 5 |
+
|
| 6 |
+
# Node artifact files
|
| 7 |
+
node_modules/
|
| 8 |
+
dist/
|
| 9 |
+
|
| 10 |
+
# Compiled Java class files
|
| 11 |
+
*.class
|
| 12 |
+
|
| 13 |
+
# Compiled Python bytecode
|
| 14 |
+
*.py[cod]
|
| 15 |
+
|
| 16 |
+
# Log files
|
| 17 |
+
*.log
|
| 18 |
+
|
| 19 |
+
# Package files
|
| 20 |
+
*.jar
|
| 21 |
+
|
| 22 |
+
# Maven
|
| 23 |
+
target/
|
| 24 |
+
dist/
|
| 25 |
+
|
| 26 |
+
# JetBrains IDE
|
| 27 |
+
.idea/
|
| 28 |
+
|
| 29 |
+
# Unit test reports
|
| 30 |
+
TEST*.xml
|
| 31 |
+
|
| 32 |
+
# Generated by MacOS
|
| 33 |
+
.DS_Store
|
| 34 |
+
|
| 35 |
+
# Generated by Windows
|
| 36 |
+
Thumbs.db
|
| 37 |
+
|
| 38 |
+
# Applications
|
| 39 |
+
*.app
|
| 40 |
+
*.exe
|
| 41 |
+
*.war
|
| 42 |
+
|
| 43 |
+
# Large media files
|
| 44 |
+
*.mp4
|
| 45 |
+
*.tiff
|
| 46 |
+
*.avi
|
| 47 |
+
*.flv
|
| 48 |
+
*.mov
|
| 49 |
+
*.wmv
|
| 50 |
+
|
| 51 |
+
# keys
|
| 52 |
+
keys.env
|
app.py
CHANGED
|
@@ -2,8 +2,10 @@ import gradio as gr
|
|
| 2 |
from pyzbar.pyzbar import decode
|
| 3 |
from lambdas import upload_models, predict
|
| 4 |
import base64
|
| 5 |
-
from io import BytesIO
|
| 6 |
from PIL import Image
|
|
|
|
|
|
|
| 7 |
|
| 8 |
DEBUG = True
|
| 9 |
|
|
@@ -21,20 +23,37 @@ navigator.mediaDevices.getUserMedia = (constraints) => {
|
|
| 21 |
"""
|
| 22 |
|
| 23 |
config = {'possible_shifts': {'No shifts': 0}, 'possible_modes': ["waste"]}
|
| 24 |
-
restaurant_id = None
|
| 25 |
-
shift_id = None
|
| 26 |
|
| 27 |
|
| 28 |
def login(username, password) -> bool:
|
| 29 |
# TODO from username and password get restaurant_id
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
def start_app(shift_id, mode):
|
|
|
|
| 2 |
from pyzbar.pyzbar import decode
|
| 3 |
from lambdas import upload_models, predict
|
| 4 |
import base64
|
| 5 |
+
from io import BytesIO, StringIO
|
| 6 |
from PIL import Image
|
| 7 |
+
import pandas as pd
|
| 8 |
+
import os.path
|
| 9 |
|
| 10 |
DEBUG = True
|
| 11 |
|
|
|
|
| 23 |
"""
|
| 24 |
|
| 25 |
config = {'possible_shifts': {'No shifts': 0}, 'possible_modes': ["waste"]}
|
|
|
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
def login(username, password) -> bool:
|
| 29 |
# TODO from username and password get restaurant_id
|
| 30 |
+
if os.path.isfile('credentials.csv'):
|
| 31 |
+
df = pd.read_csv('credentials.csv')
|
| 32 |
+
else:
|
| 33 |
+
s = os.environ.get('CREDENTIALS')
|
| 34 |
+
df = pd.read_csv(StringIO(s))
|
| 35 |
+
|
| 36 |
+
if not len(df):
|
| 37 |
+
return False
|
| 38 |
+
|
| 39 |
+
for idx, row in df.iterrows():
|
| 40 |
+
if row['username'] == username and row['password'] == password:
|
| 41 |
+
restaurant_id = int(row['restaurant_id'])
|
| 42 |
+
restaurant_name = str(row['restaurant_name'])
|
| 43 |
+
mode = 'waste'
|
| 44 |
+
possible_modes = str(row.get('modes')).split(':')
|
| 45 |
+
possible_shifts = {i.split(':')[0]: i.split(':')[1] for i in str(row.get('shifts')).split('-')}
|
| 46 |
+
|
| 47 |
+
config_aux = {'restaurant_id': restaurant_id,
|
| 48 |
+
'restaurant_name': restaurant_name,
|
| 49 |
+
'mode': mode,
|
| 50 |
+
'possible_modes': possible_modes,
|
| 51 |
+
'possible_shifts': possible_shifts,
|
| 52 |
+
}
|
| 53 |
+
config.update(config_aux)
|
| 54 |
+
|
| 55 |
+
return True
|
| 56 |
+
return False
|
| 57 |
|
| 58 |
|
| 59 |
def start_app(shift_id, mode):
|
requirements.txt
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
pyzbar
|
| 2 |
pillow
|
| 3 |
-
boto3
|
| 4 |
-
libzbar0
|
|
|
|
| 1 |
pyzbar
|
| 2 |
pillow
|
| 3 |
+
boto3
|
|
|