Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -8,26 +8,17 @@ from qwen_vl_utils import process_vision_info
|
|
| 8 |
|
| 9 |
# Specify the model path or identifier.
|
| 10 |
MODEL_PATH = "Ananthu01/qwen2.5_vl_finetuned_model"
|
| 11 |
-
# MODEL_PATH = "Qwen/Qwen2.5-VL-3B-Instruct"
|
| 12 |
|
| 13 |
# Initialize the Qwen2.5 VL model.
|
| 14 |
-
# model = AutoModel.from_pretrained(
|
| 15 |
-
# MODEL_PATH,
|
| 16 |
-
# trust_remote_code=True,
|
| 17 |
-
# device_map="cpu" # Ensures the model is loaded on CPU.
|
| 18 |
-
# )
|
| 19 |
-
|
| 20 |
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 21 |
MODEL_PATH,
|
| 22 |
trust_remote_code=True,
|
| 23 |
device_map="cpu", # Ensures the model is loaded on CPU.
|
| 24 |
-
wbits=4, # Example parameter for 4-bit quantization
|
| 25 |
-
groupsize=128, # Example parameter for groupsize setting
|
| 26 |
use_safetensors=True
|
| 27 |
)
|
| 28 |
|
| 29 |
# Load the processor.
|
| 30 |
-
processor = AutoProcessor.from_pretrained(
|
| 31 |
|
| 32 |
# Load the tokenizer.
|
| 33 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True)
|
|
@@ -124,3 +115,4 @@ async def generate_output(image_file: UploadFile = File(...)):
|
|
| 124 |
|
| 125 |
# Return the generated text.
|
| 126 |
return generated_text
|
|
|
|
|
|
| 8 |
|
| 9 |
# Specify the model path or identifier.
|
| 10 |
MODEL_PATH = "Ananthu01/qwen2.5_vl_finetuned_model"
|
|
|
|
| 11 |
|
| 12 |
# Initialize the Qwen2.5 VL model.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 14 |
MODEL_PATH,
|
| 15 |
trust_remote_code=True,
|
| 16 |
device_map="cpu", # Ensures the model is loaded on CPU.
|
|
|
|
|
|
|
| 17 |
use_safetensors=True
|
| 18 |
)
|
| 19 |
|
| 20 |
# Load the processor.
|
| 21 |
+
processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-3B-Instruct", trust_remote_code=True)
|
| 22 |
|
| 23 |
# Load the tokenizer.
|
| 24 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True)
|
|
|
|
| 115 |
|
| 116 |
# Return the generated text.
|
| 117 |
return generated_text
|
| 118 |
+
|