Spaces:
Sleeping
Sleeping
Commit
·
1907678
1
Parent(s):
2025471
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ from flask import Flask, request
|
|
2 |
from transformers import AutoModelForImageClassification
|
3 |
from transformers import AutoImageProcessor
|
4 |
from PIL import Image
|
|
|
5 |
import torch
|
6 |
|
7 |
app = Flask(__name__)
|
@@ -18,8 +19,8 @@ def upload_image():
|
|
18 |
image_file = request.files['image']
|
19 |
|
20 |
# Save the image file to a desired location on the server
|
21 |
-
image_path = "assets/
|
22 |
-
image_file.save(
|
23 |
|
24 |
# You can perform additional operations with the image here
|
25 |
# ...
|
@@ -29,7 +30,7 @@ def upload_image():
|
|
29 |
|
30 |
@app.route('/get_text', methods=['GET'])
|
31 |
def get_text():
|
32 |
-
image = Image.open('
|
33 |
inputs = image_processor(image, return_tensors="pt")
|
34 |
|
35 |
with torch.no_grad():
|
|
|
2 |
from transformers import AutoModelForImageClassification
|
3 |
from transformers import AutoImageProcessor
|
4 |
from PIL import Image
|
5 |
+
import os
|
6 |
import torch
|
7 |
|
8 |
app = Flask(__name__)
|
|
|
19 |
image_file = request.files['image']
|
20 |
|
21 |
# Save the image file to a desired location on the server
|
22 |
+
# image_path = "assets/"
|
23 |
+
image_file.save(os.path.join('/', 'img.jpg'))
|
24 |
|
25 |
# You can perform additional operations with the image here
|
26 |
# ...
|
|
|
30 |
|
31 |
@app.route('/get_text', methods=['GET'])
|
32 |
def get_text():
|
33 |
+
image = Image.open('/img.jpg')
|
34 |
inputs = image_processor(image, return_tensors="pt")
|
35 |
|
36 |
with torch.no_grad():
|