""" Main script for running multi-modal inference using Helium framework. Example usage for end users. """ import os from inference_runner import InferenceRunner def run_inference_example(): """Example showing how to use the inference runner""" # Path to your model checkpoint MODEL_PATH = os.path.join(os.path.dirname(__file__), "checkpoints/model") # Initialize the inference runner print("Initializing inference runner...") runner = InferenceRunner( model_path=MODEL_PATH, device_id="vgpu0", # Use first virtual GPU batch_size=4, # Process 4 items at once cache_dir="cache" # Cache results here ) try: # Example 1: Single inference with text only print("\nRunning text-only inference...") result = runner(text="Analyze this sentence.") print("Text features shape:", result["text_features"].shape) # Example 2: Multi-modal inference print("\nRunning multi-modal inference...") result = runner( text="Describe this image and sound:", image_path="samples/scene.jpg", audio_path="samples/audio.wav" ) print("Available features:", list(result.keys())) # Example 3: Batch processing print("\nProcessing batch...") texts = [f"Sample text {i}" for i in range(3)] images = ["samples/img1.jpg", "samples/img2.jpg", "samples/img3.jpg"] for text, img in zip(texts, images): runner.add_to_batch(text=text, image_path=img) batch_result = runner.process_batch() print("Batch processing complete. Output shapes:") for key, value in batch_result.items(): print(f" {key}: {value.shape}") # Example 4: Generate from multi-modal context print("\nGenerating text from multi-modal context...") generated = runner.generate_from_context( context_text="What's happening in this scene?", context_image="samples/scene.jpg", context_audio="samples/ambient.wav", max_length=50 ) print("Generated sequence shape:", generated.shape) finally: # Always cleanup print("\nCleaning up resources...") runner.cleanup() def main(): """Main entry point""" try: run_inference_example() print("\nInference completed successfully!") except FileNotFoundError as e: print(f"\nError: Required file not found: {e}") print("Please make sure all model files and samples are in the correct location.") except ValueError as e: print(f"\nError: Invalid input: {e}") print("Please check your input values and formats.") except Exception as e: print(f"\nUnexpected error: {e}") print("If this persists, please check the logs or contact support.") if __name__ == "__main__": main()