ScouterAI / modal_apps /inference_pipeline.py
stevenbucaille's picture
Enhance app.py with improved user interface and instructions, update model ID in llm.py, and add image classification capabilities across various components. Introduce segment anything functionality and refine README for clarity on model capabilities.
518d841
raw
history blame
570 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, **kwargs):
try:
pipe = pipeline(task=task, model=model_name, device="cuda")
result = pipe(image, **kwargs)
return result
except Exception as e:
raise Exception(f"Error in inference pipeline: {e}. Please try again with a different model.")