Spaces:
Sleeping
Sleeping
commented few lines
Browse files
app.py
CHANGED
|
@@ -32,29 +32,29 @@ model = MllamaForConditionalGeneration.from_pretrained(
|
|
| 32 |
model.to(device)
|
| 33 |
processor = AutoProcessor.from_pretrained(model_name, use_auth_token=HF_TOKEN)
|
| 34 |
|
| 35 |
-
@spaces.GPU # Use the free GPU provided by Hugging Face Spaces
|
| 36 |
-
def predict(image, text):
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
def predict_text(text):
|
| 59 |
# Prepare the input messages
|
| 60 |
messages = [{"role": "user", "content": [{"type": "text", "text": text}]}]
|
|
|
|
| 32 |
model.to(device)
|
| 33 |
processor = AutoProcessor.from_pretrained(model_name, use_auth_token=HF_TOKEN)
|
| 34 |
|
| 35 |
+
# @spaces.GPU # Use the free GPU provided by Hugging Face Spaces
|
| 36 |
+
# def predict(image, text):
|
| 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 |
+
# ]
|
| 44 |
|
| 45 |
+
# # Create the input text using the processor's chat template
|
| 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)
|
| 53 |
|
| 54 |
+
# # Decode the output to return the final response
|
| 55 |
+
# response = processor.decode(outputs[0], skip_special_tokens=True)
|
| 56 |
+
# return response
|
| 57 |
+
# @spaces.GPU
|
| 58 |
def predict_text(text):
|
| 59 |
# Prepare the input messages
|
| 60 |
messages = [{"role": "user", "content": [{"type": "text", "text": text}]}]
|