Spaces:
Runtime error
Runtime error
Commit
·
495df52
1
Parent(s):
0b1df81
Set inputs to CPU for compatibility without GPU
Browse filesUpdated the input configuration to use the CPU instead of GPU, ensuring broader compatibility for environments lacking a GPU. This change enhances the application's accessibility, allowing users to run predictions without specific hardware requirements.
app.py
CHANGED
|
@@ -11,7 +11,7 @@ processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct")
|
|
| 11 |
async def predict(messages: list):
|
| 12 |
# Processamento e inferência
|
| 13 |
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 14 |
-
inputs = processor(text=[text], padding=True, return_tensors="pt").to("
|
| 15 |
generated_ids = model.generate(**inputs, max_new_tokens=128)
|
| 16 |
output_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
| 17 |
return {"response": output_text}
|
|
|
|
| 11 |
async def predict(messages: list):
|
| 12 |
# Processamento e inferência
|
| 13 |
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 14 |
+
inputs = processor(text=[text], padding=True, return_tensors="pt").to("cpu") # Altere para "cpu" se não tiver GPU
|
| 15 |
generated_ids = model.generate(**inputs, max_new_tokens=128)
|
| 16 |
output_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
|
| 17 |
return {"response": output_text}
|