Update app.py
Browse files
app.py
CHANGED
@@ -11,15 +11,15 @@ import torch
|
|
11 |
import tempfile
|
12 |
import whisper
|
13 |
import json
|
14 |
-
import uvicorn
|
15 |
app = Flask(__name__)
|
16 |
from deep_translator import GoogleTranslator
|
17 |
|
18 |
CORS(app, resources={r"/*": {"origins": "*"}}) # Enable CORS for all routes
|
19 |
# Load MedGemma model (4B) on startup
|
20 |
-
from asgiref.wsgi import WsgiToAsgi
|
21 |
|
22 |
-
asgi_app = WsgiToAsgi(app) # for uvicorn compatibility
|
23 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
24 |
#from huggingface_hub import login
|
25 |
import os
|
@@ -46,7 +46,7 @@ model_id = "google/medgemma-4b-pt"
|
|
46 |
model_medg = AutoModelForImageTextToText.from_pretrained(
|
47 |
model_id,
|
48 |
torch_dtype=torch.bfloat16,
|
49 |
-
device_map="
|
50 |
)
|
51 |
processor = AutoProcessor.from_pretrained(model_id)
|
52 |
@app.route('/analyze-image', methods=['POST'])
|
|
|
11 |
import tempfile
|
12 |
import whisper
|
13 |
import json
|
14 |
+
#import uvicorn
|
15 |
app = Flask(__name__)
|
16 |
from deep_translator import GoogleTranslator
|
17 |
|
18 |
CORS(app, resources={r"/*": {"origins": "*"}}) # Enable CORS for all routes
|
19 |
# Load MedGemma model (4B) on startup
|
20 |
+
#from asgiref.wsgi import WsgiToAsgi
|
21 |
|
22 |
+
#asgi_app = WsgiToAsgi(app) # for uvicorn compatibility
|
23 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
24 |
#from huggingface_hub import login
|
25 |
import os
|
|
|
46 |
model_medg = AutoModelForImageTextToText.from_pretrained(
|
47 |
model_id,
|
48 |
torch_dtype=torch.bfloat16,
|
49 |
+
device_map="cpu",
|
50 |
)
|
51 |
processor = AutoProcessor.from_pretrained(model_id)
|
52 |
@app.route('/analyze-image', methods=['POST'])
|