Update app.py
Browse files
app.py
CHANGED
|
@@ -13,24 +13,18 @@ model = VisionEncoderDecoderModel.from_pretrained("./donut-base-finetuned-inv")
|
|
| 13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 14 |
model.to(device)
|
| 15 |
|
| 16 |
-
def send_to_telegram(message):
|
| 17 |
-
|
| 18 |
-
apiToken = os.getenv('TELEGRAM_BOT_TOKEN')
|
| 19 |
-
chatID = os.getenv('TELEGRAM_CHANNEL_ID')
|
| 20 |
-
apiURL = f'https://api.telegram.org/bot{apiToken}/sendMessage'
|
| 21 |
-
try:
|
| 22 |
-
response = requests.post(apiURL, json={'chat_id': chatID, 'text': message})
|
| 23 |
-
#print(response.text)
|
| 24 |
-
#except Exception as e:
|
| 25 |
-
#print(e)
|
| 26 |
-
|
| 27 |
def process_document(image):
|
| 28 |
#save uploaded file locally
|
| 29 |
im1 = Image.fromarray(image)
|
| 30 |
im1 = im1.save("./geeks.jpg")
|
| 31 |
|
| 32 |
#send notification through telegram
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# prepare encoder inputs
|
| 36 |
pixel_values = processor(image, return_tensors="pt").pixel_values
|
|
|
|
| 13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 14 |
model.to(device)
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def process_document(image):
|
| 17 |
#save uploaded file locally
|
| 18 |
im1 = Image.fromarray(image)
|
| 19 |
im1 = im1.save("./geeks.jpg")
|
| 20 |
|
| 21 |
#send notification through telegram
|
| 22 |
+
message="Hello from HuggingFace!"
|
| 23 |
+
apiToken = os.getenv('TELEGRAM_BOT_TOKEN')
|
| 24 |
+
chatID = os.getenv('TELEGRAM_CHANNEL_ID')
|
| 25 |
+
apiURL = f'https://api.telegram.org/bot{apiToken}/sendMessage'
|
| 26 |
+
try:
|
| 27 |
+
response = requests.post(apiURL, json={'chat_id': chatID, 'text': message})
|
| 28 |
|
| 29 |
# prepare encoder inputs
|
| 30 |
pixel_values = processor(image, return_tensors="pt").pixel_values
|