Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,4 @@
|
|
| 1 |
-
|
| 2 |
-
# Retrieve the token from environment variables
|
| 3 |
-
#api_token = os.getenv("HF_TOKEN").strip()
|
| 4 |
-
|
| 5 |
import torch
|
| 6 |
from flask import Flask, request, jsonify
|
| 7 |
from transformers import AutoModel, AutoTokenizer, BitsAndBytesConfig
|
|
@@ -9,6 +6,9 @@ from PIL import Image
|
|
| 9 |
import io
|
| 10 |
import base64
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
app = Flask(__name__)
|
| 13 |
|
| 14 |
# Quantization configuration
|
|
@@ -19,19 +19,20 @@ bnb_config = BitsAndBytesConfig(
|
|
| 19 |
bnb_4bit_compute_dtype=torch.float16
|
| 20 |
)
|
| 21 |
|
| 22 |
-
# Load model
|
| 23 |
model = AutoModel.from_pretrained(
|
| 24 |
"ContactDoctor/Bio-Medical-MultiModal-Llama-3-8B-V1",
|
| 25 |
quantization_config=bnb_config,
|
| 26 |
device_map="auto",
|
| 27 |
torch_dtype=torch.float16,
|
| 28 |
-
trust_remote_code=True,
|
| 29 |
-
|
| 30 |
)
|
| 31 |
|
| 32 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 33 |
"ContactDoctor/Bio-Medical-MultiModal-Llama-3-8B-V1",
|
| 34 |
-
trust_remote_code=True
|
|
|
|
| 35 |
)
|
| 36 |
|
| 37 |
def decode_base64_image(base64_string):
|
|
@@ -74,7 +75,5 @@ def analyze_input():
|
|
| 74 |
'message': str(e)
|
| 75 |
}), 500
|
| 76 |
|
| 77 |
-
|
| 78 |
if __name__ == '__main__':
|
| 79 |
-
app.run(debug=True)
|
| 80 |
-
|
|
|
|
| 1 |
+
import os
|
|
|
|
|
|
|
|
|
|
| 2 |
import torch
|
| 3 |
from flask import Flask, request, jsonify
|
| 4 |
from transformers import AutoModel, AutoTokenizer, BitsAndBytesConfig
|
|
|
|
| 6 |
import io
|
| 7 |
import base64
|
| 8 |
|
| 9 |
+
# Get API token from environment variable
|
| 10 |
+
api_token = os.getenv("HF_TOKEN").strip()
|
| 11 |
+
|
| 12 |
app = Flask(__name__)
|
| 13 |
|
| 14 |
# Quantization configuration
|
|
|
|
| 19 |
bnb_4bit_compute_dtype=torch.float16
|
| 20 |
)
|
| 21 |
|
| 22 |
+
# Load model without Flash Attention
|
| 23 |
model = AutoModel.from_pretrained(
|
| 24 |
"ContactDoctor/Bio-Medical-MultiModal-Llama-3-8B-V1",
|
| 25 |
quantization_config=bnb_config,
|
| 26 |
device_map="auto",
|
| 27 |
torch_dtype=torch.float16,
|
| 28 |
+
trust_remote_code=True,
|
| 29 |
+
token=api_token
|
| 30 |
)
|
| 31 |
|
| 32 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 33 |
"ContactDoctor/Bio-Medical-MultiModal-Llama-3-8B-V1",
|
| 34 |
+
trust_remote_code=True,
|
| 35 |
+
token=api_token
|
| 36 |
)
|
| 37 |
|
| 38 |
def decode_base64_image(base64_string):
|
|
|
|
| 75 |
'message': str(e)
|
| 76 |
}), 500
|
| 77 |
|
|
|
|
| 78 |
if __name__ == '__main__':
|
| 79 |
+
app.run(debug=True)
|
|
|