Update app.py
Browse files
app.py
CHANGED
|
@@ -1,46 +1,46 @@
|
|
| 1 |
-
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__)
|
| 8 |
|
| 9 |
-
model = AutoModelForImageClassification.from_pretrained(
|
| 10 |
-
|
| 11 |
-
image_processor = AutoImageProcessor.from_pretrained(
|
| 12 |
-
|
| 13 |
|
| 14 |
|
| 15 |
-
@app.route('/upload_image', methods=['POST'])
|
| 16 |
-
def upload_image():
|
| 17 |
-
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
|
| 30 |
-
@app.route('/get_text', methods=['GET'])
|
| 31 |
-
def get_text():
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
|
| 45 |
-
if __name__ == '__app__':
|
| 46 |
-
|
|
|
|
| 1 |
+
# 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__)
|
| 8 |
|
| 9 |
+
# model = AutoModelForImageClassification.from_pretrained(
|
| 10 |
+
# './myModel')
|
| 11 |
+
# image_processor = AutoImageProcessor.from_pretrained(
|
| 12 |
+
# "google/vit-base-patch16-224-in21k")
|
| 13 |
|
| 14 |
|
| 15 |
+
# @app.route('/upload_image', methods=['POST'])
|
| 16 |
+
# def upload_image():
|
| 17 |
+
# # Get the image file from the request
|
| 18 |
+
# image_file = request.files['image']
|
| 19 |
|
| 20 |
+
# # Save the image file to a desired location on the server
|
| 21 |
+
# image_path = "assets/img.jpg"
|
| 22 |
+
# image_file.save(image_path)
|
| 23 |
|
| 24 |
+
# # You can perform additional operations with the image here
|
| 25 |
+
# # ...
|
| 26 |
|
| 27 |
+
# return 'Image uploaded successfully'
|
| 28 |
|
| 29 |
|
| 30 |
+
# @app.route('/get_text', methods=['GET'])
|
| 31 |
+
# def get_text():
|
| 32 |
+
# image = Image.open('assets/img.jpg')
|
| 33 |
+
# inputs = image_processor(image, return_tensors="pt")
|
| 34 |
|
| 35 |
+
# with torch.no_grad():
|
| 36 |
+
# logits = model(**inputs).logits
|
| 37 |
|
| 38 |
+
# predicted_label = logits.argmax(-1).item()
|
| 39 |
|
| 40 |
+
# disease = model.config.id2label[predicted_label]
|
| 41 |
|
| 42 |
+
# return disease
|
| 43 |
|
| 44 |
|
| 45 |
+
# if __name__ == '__app__':
|
| 46 |
+
# app.run( host='192.168.1.1',port=8080)
|