cxr_llava / app.py
jcsagar's picture
Update app.py
d8f3530 verified
raw
history blame
795 Bytes
import gradio as gr
from transformers import AutoModel
from PIL import Image
import torch
import os
from huggingface_hub import login
# Load the model
model = AutoModel.from_pretrained("jcsagar/CXR-LLAVA-v2", trust_remote_code=True)
model = model.to("cuda")
# Define the function to generate the report
def generate_report(image):
image = Image.open(image).convert("RGB")
response = model.write_radiologic_report(image)
return response
# Create the Gradio interface
interface = gr.Interface(
fn=generate_report,
inputs=gr.Image(type="filepath", label="Upload Image"),
outputs=gr.Textbox(label="Report"),
title="CXR Report Creator",
description="Upload an image to use with the CXR-LLAVA-v2 model."
)
# Launch the interface with API enabled
interface.launch()