Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,17 +4,19 @@ import torch
|
|
4 |
MODEL_NAME = "RPW/NIH-1.2_Llama-3.2-11B-Vision-Instruct"
|
5 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
6 |
|
|
|
|
|
7 |
# Load the tokenizer and model
|
8 |
tokenizer = RobertaTokenizer.from_pretrained(MODEL_NAME)
|
9 |
model = RobertaForSequenceClassification.from_pretrained(MODEL_NAME).to(device)
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
logits = outputs.logits
|
18 |
|
19 |
-
|
20 |
-
|
|
|
|
4 |
MODEL_NAME = "RPW/NIH-1.2_Llama-3.2-11B-Vision-Instruct"
|
5 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
6 |
|
7 |
+
instruction = "You are an expert radiographer. Describe accurately what you see in this image."
|
8 |
+
|
9 |
# Load the tokenizer and model
|
10 |
tokenizer = RobertaTokenizer.from_pretrained(MODEL_NAME)
|
11 |
model = RobertaForSequenceClassification.from_pretrained(MODEL_NAME).to(device)
|
12 |
|
13 |
+
input_text = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
|
14 |
+
inputs = tokenizer(
|
15 |
+
image,
|
16 |
+
input_text,
|
17 |
+
add_special_tokens=False,
|
18 |
+
return_tensors="pt").to("cuda")
|
|
|
19 |
|
20 |
+
text_streamer = TextStreamer(tokenizer, skip_prompt=True)
|
21 |
+
_ = model.generate(**inputs, streamer=text_streamer, max_new_tokens=128,
|
22 |
+
use_cache=True, temperature=1.5, min_p=0.1)
|