ScouterAI / modal_apps /inference_pipeline.py
stevenbucaille's picture
Enhance image processing capabilities and update project structure
111afa2
raw
history blame
550 Bytes
import modal
from smolagents import Tool
from transformers import pipeline
from .app import app
from .image import image
@app.cls(gpu="T4", image=image)
class InferencePipelineModalApp:
@modal.method()
def forward(self, task: str, model_name: str, image):
try:
pipe = pipeline(task=task, model=model_name, device="cuda")
result = pipe(image)
return result
except Exception as e:
raise Exception(f"Error in inference pipeline: {e}. Please try again with a different model.")