RPW commited on
Commit
6de0aed
·
verified ·
1 Parent(s): 0dde4ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -1,18 +1,20 @@
1
- from transformers import AutoTokenizer, AutoModelForVision2Seq
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 = AutoTokenizer.from_pretrained(MODEL_NAME)
10
- model = AutoModelForVision2Seq.from_pretrained(MODEL_NAME).to(device)
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
- output = model.generate(**inputs)
18
- print(tokenizer.decode(output[0], skip_special_tokens=True))
 
 
 
 
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)