Spaces:
Sleeping
Sleeping
meta-llama
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ print(f"Low memory mode: {LOW_MEMORY}")
|
|
20 |
HF_TOKEN = os.environ.get('HF_TOKEN')
|
21 |
|
22 |
# Load the model and processor
|
23 |
-
model_name = "
|
24 |
model = MllamaForConditionalGeneration.from_pretrained(
|
25 |
model_name,
|
26 |
use_auth_token=HF_TOKEN,
|
@@ -37,7 +37,7 @@ def predict(image, text):
|
|
37 |
# Prepare the input messages
|
38 |
messages = [
|
39 |
{"role": "user", "content": [
|
40 |
-
|
41 |
{"type": "text", "text": text} # Add the user-provided text input
|
42 |
]}
|
43 |
]
|
@@ -46,7 +46,7 @@ def predict(image, text):
|
|
46 |
input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
|
47 |
|
48 |
# Process the inputs and move to the appropriate device
|
49 |
-
inputs = processor(input_text, return_tensors="pt").to(device)
|
50 |
|
51 |
# Generate a response from the model
|
52 |
outputs = model.generate(**inputs, max_new_tokens=100)
|
|
|
20 |
HF_TOKEN = os.environ.get('HF_TOKEN')
|
21 |
|
22 |
# Load the model and processor
|
23 |
+
model_name = "meta-llama/Llama-3.2-11B-Vision-Instruct"
|
24 |
model = MllamaForConditionalGeneration.from_pretrained(
|
25 |
model_name,
|
26 |
use_auth_token=HF_TOKEN,
|
|
|
37 |
# Prepare the input messages
|
38 |
messages = [
|
39 |
{"role": "user", "content": [
|
40 |
+
{"type": "image"}, # Specify that an image is provided
|
41 |
{"type": "text", "text": text} # Add the user-provided text input
|
42 |
]}
|
43 |
]
|
|
|
46 |
input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
|
47 |
|
48 |
# Process the inputs and move to the appropriate device
|
49 |
+
inputs = processor(image, input_text, return_tensors="pt").to(device)
|
50 |
|
51 |
# Generate a response from the model
|
52 |
outputs = model.generate(**inputs, max_new_tokens=100)
|