from transformers import AutoProcessor, AutoModel from PIL import Image from config import HF_IMAGE_MODEL, HF_TOKEN # Load the Hugging Face model for medical image analysis model = AutoModel.from_pretrained(HF_IMAGE_MODEL, trust_remote_code=True) processor = AutoProcessor.from_pretrained(HF_IMAGE_MODEL) def analyze_medical_image(image_file): """ Process and analyze a medical image to generate diagnostic insights. """ image = Image.open(image_file).convert("RGB") inputs = processor(images=image, return_tensors="pt") outputs = model.generate(**inputs, max_length=256) return processor.decode(outputs[0], skip_special_tokens=True)