|
import gradio as gr |
|
from transformers import AutoModel |
|
from PIL import Image |
|
import torch |
|
import os |
|
from huggingface_hub import login |
|
import spaces |
|
|
|
|
|
model = AutoModel.from_pretrained("jcsagar/CXR-LLAVA-v2", trust_remote_code=True) |
|
model = model.to("cuda") |
|
|
|
|
|
@spaces.GPU |
|
def ask_question(question, image): |
|
image = Image.open(image).convert("RGB") |
|
response = model.ask_question(question, image) |
|
return response |
|
|
|
|
|
interface = gr.Interface( |
|
fn=ask_question, |
|
inputs=[gr.Textbox(lines=1, placeholder="Enter your question here", label="Question"), |
|
gr.Image(type="filepath", label="Upload Image")], |
|
outputs=gr.Textbox(label="Report"), |
|
title="CXR Report Creator", |
|
description="Upload an image and enter a question to use with the CXR-LLAVA-v2 model." |
|
) |
|
|
|
|
|
interface.launch() |
|
|