Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
-
from transformers import
|
2 |
import torch
|
3 |
-
|
4 |
# Define the model path
|
5 |
MODEL_NAME = "RPW/NIH-1.2_Llama-3.2-11B-Vision-Instruct"
|
6 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
7 |
|
8 |
# Load the tokenizer and model
|
9 |
-
tokenizer =
|
10 |
-
model =
|
11 |
|
12 |
# Example usage: Tokenizing some input text
|
13 |
input_text = "Describe this image."
|
14 |
inputs = tokenizer(input_text, return_tensors="pt").to(device)
|
15 |
|
16 |
# Generating output
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
1 |
+
from transformers import RobertaTokenizer, RobertaForSequenceClassification
|
2 |
import torch
|
|
|
3 |
# Define the model path
|
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 |
# Example usage: Tokenizing some input text
|
12 |
input_text = "Describe this image."
|
13 |
inputs = tokenizer(input_text, return_tensors="pt").to(device)
|
14 |
|
15 |
# Generating output
|
16 |
+
outputs = model(**inputs)
|
17 |
+
logits = outputs.logits
|
18 |
+
|
19 |
+
# ใช้ softmax หรือการแปลงค่าอื่นๆ ถ้าต้องการผลลัพธ์ที่เหมาะสมกับการ classification
|
20 |
+
print(logits)
|