CaesarCloudSync commited on
Commit
a350783
1 Parent(s): 3c86687

CaesarAI Handwriting

Browse files
CaesarFinance/caesarfinance.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import requests
2
  from decouple import config
3
 
@@ -40,6 +42,14 @@ class CaesarFinance:
40
  return False
41
  else:
42
  return False
 
 
 
 
 
 
 
 
43
 
44
 
45
 
@@ -63,9 +73,53 @@ if __name__ == "__main__":
63
  access_phone_auth = False
64
  while access_phone_auth == False:
65
  access_phone_auth = caesarfinance.phone_auth()
66
-
67
-
68
  accountinfo = caesarfinance.get_accounts()
69
- print(accountinfo)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  #caesarfinance.get_access_code()
 
1
+ import os
2
+ import json
3
  import requests
4
  from decouple import config
5
 
 
42
  return False
43
  else:
44
  return False
45
+ def get_balance(self,account_id):
46
+ response = requests.get("https://api.monzo.com/balance",params={"account_id":account_id},headers={'Authorization': 'Bearer ' + self.access_token})
47
+ return response.json()
48
+ # get balance
49
+ def get_transactions(self,account_id):
50
+ response = requests.get("https://api.monzo.com/transactions",params={"account_id":account_id},headers={'Authorization': 'Bearer ' + self.access_token})
51
+ return response.json()
52
+
53
 
54
 
55
 
 
73
  access_phone_auth = False
74
  while access_phone_auth == False:
75
  access_phone_auth = caesarfinance.phone_auth()
 
 
76
  accountinfo = caesarfinance.get_accounts()
77
+ personal = accountinfo["accounts"][0]["id"]
78
+ business = accountinfo["accounts"][-1]["id"]
79
+
80
+ monzo_authorized = True if "accounts" in accountinfo else False
81
+ while monzo_authorized == True:
82
+ # get the command from prompt
83
+ cfin = "caesar"
84
+ cwd = os.getcwd()
85
+ command = input(f"<caesarmonzo> {cwd} $> ")
86
+ if command == f"{cfin} --help":
87
+ with open(f"caesarfinhelp.txt","r") as f:
88
+ helpinfo = f.read()
89
+ print(helpinfo)
90
+ if command == f"{cfin} accounts" or command == f"{cfin} -a":
91
+ accountinfo = caesarfinance.get_accounts()
92
+ print(accountinfo)
93
+ if command == f"{cfin} accounts -b personal":
94
+ transactioninfo = caesarfinance.get_balance(personal)
95
+ print(transactioninfo)
96
+ if command == f"{cfin} accounts -b business":
97
+ transactioninfo = caesarfinance.get_balance(business)
98
+ print(transactioninfo)
99
+ if command == f"{cfin} accounts -t personal":
100
+ transactioninfo = caesarfinance.get_transactions(personal)
101
+ if "--save" in command:
102
+ with open("caesarpersonaltransactions.json","w+") as f:
103
+ json.dump(transactioninfo,f)
104
+ print(transactioninfo)
105
+ if command == f"{cfin} accounts -t business":
106
+ transactioninfo = caesarfinance.get_transactions(business)
107
+ if "--save" in command:
108
+ with open("caesarbusinesstransactions.json","w+") as f:
109
+ json.dump(transactioninfo,f)
110
+ print(transactioninfo)
111
+
112
+
113
+
114
+ if not command.strip():
115
+ # empty command
116
+ continue
117
+ if command.lower() == "exit":
118
+ # if the command is exit, just break out of the loop
119
+ break
120
+
121
+
122
+
123
+
124
 
125
  #caesarfinance.get_access_code()
CaesarFinance/caesarfinhelp.txt ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ sage: conda-script.py [-h] [-V] command ...
2
+
3
+ conda is a tool for managing and deploying applications, environments and packages.
4
+
5
+ Options:
6
+
7
+ positional arguments:
8
+ command
9
+ clean Remove unused packages and caches.
10
+ compare Compare packages between conda environments.
11
+ config Modify configuration values in .condarc.
12
+ This is modeled after the git config
13
+ command. Writes to the user .condarc file
14
+ (C:\Users\amari\.condarc) by default.
15
+ create Create a new conda environment from a list
16
+ of specified packages.
17
+ help Displays a list of available conda commands
18
+ and their help strings.
19
+ info Display information about current conda
20
+ install.
21
+ init Initialize conda for shell interaction.
22
+ [Experimental]
23
+ install Installs a list of packages into a specified
24
+ conda environment.
25
+ list List linked packages in a conda environment.
26
+ package Low-level conda package utility.
27
+ (EXPERIMENTAL)
28
+ remove Remove a list of packages from a specified
29
+ conda environment.
30
+ uninstall Alias for conda remove.
31
+ run Run an executable in a conda environment.
32
+ search Search for packages and display associated
33
+ information. The input is a MatchSpec, a
34
+ query language for conda packages. See
35
+ examples below.
36
+ update Updates conda packages to the latest
37
+ compatible version.
38
+ upgrade Alias for conda update.
39
+
40
+ optional arguments:
41
+ -h, --help Show this help message and exit.
42
+ -V, --version Show the conda version number and exit.
43
+
44
+ conda commands available from other packages:
45
+ content-trust
46
+ env
CaesarHandwriting/caesarhandwriting.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import TrOCRProcessor, VisionEncoderDecoderModel
2
+ from PIL import Image
3
+ import requests
4
+
5
+ # load image from the IAM database
6
+ class CaesarHandWriting:
7
+ def __init__(self) -> None:
8
+ self.processor = TrOCRProcessor.from_pretrained('microsoft/trocr-large-handwritten')
9
+ self.model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-large-handwritten')
10
+ def translate(self,url='https://fki.tic.heia-fr.ch/static/img/a01-122-02-00.jpg'):
11
+ image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
12
+ pixel_values = self.processor(images=image, return_tensors="pt").pixel_values
13
+ generated_ids = self.model.generate(pixel_values)
14
+ generated_text = self.processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
15
+ return generated_text
main.py CHANGED
@@ -29,11 +29,13 @@ from csv_to_db import ImportCSV
29
  from RequestModels import *
30
  from CaesarFaceRecognition.caesardeepface import CaesarDeepFace
31
  from CaesarAIART.caesaraiart import CaesarAIART
 
32
  #from CaesarAIMusicLoad.caesaraimusicload import CaesarAITelegramBOT
33
 
34
  importcsv = ImportCSV("CaesarAI")
35
  caesaryolo = CaesarYolo()
36
  caesarfacedetectmodel = CaesarFaceDetection()
 
37
  #caesartelgegrambot = CaesarAITelegramBOT()
38
 
39
  app = FastAPI()
@@ -55,6 +57,11 @@ def caesaraihome():
55
  def caesarailogo():
56
  return FileResponse(f"{CURRENT_DIR}/CaesarAILogo.png")
57
 
 
 
 
 
 
58
 
59
  @app.websocket("/caesarobjectdetectws")
60
  async def caesarobjectdetectws(websocket: WebSocket):
 
29
  from RequestModels import *
30
  from CaesarFaceRecognition.caesardeepface import CaesarDeepFace
31
  from CaesarAIART.caesaraiart import CaesarAIART
32
+ from CaesarHandwriting.caesarhandwriting import CaesarHandWriting
33
  #from CaesarAIMusicLoad.caesaraimusicload import CaesarAITelegramBOT
34
 
35
  importcsv = ImportCSV("CaesarAI")
36
  caesaryolo = CaesarYolo()
37
  caesarfacedetectmodel = CaesarFaceDetection()
38
+ caesarhandwriting = CaesarHandWriting()
39
  #caesartelgegrambot = CaesarAITelegramBOT()
40
 
41
  app = FastAPI()
 
57
  def caesarailogo():
58
  return FileResponse(f"{CURRENT_DIR}/CaesarAILogo.png")
59
 
60
+ @app.get("/caesaraihandwriting")
61
+ def caesaraihandwriting():
62
+ text = caesarhandwriting.translate()
63
+ return {"message":text}
64
+
65
 
66
  @app.websocket("/caesarobjectdetectws")
67
  async def caesarobjectdetectws(websocket: WebSocket):