File size: 938 Bytes
8446093 0a32a5c 2a472f8 03728a5 1d02de0 8446093 0a32a5c 03728a5 d8f3530 8446093 0a32a5c 1d02de0 3e5c162 0a32a5c 3e5c162 0a32a5c 8446093 0a32a5c 3e5c162 0506c40 3e5c162 8446093 2a472f8 fb5c2f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import gradio as gr
from transformers import AutoModel
from PIL import Image
import torch
import os
from huggingface_hub import login
import spaces
# 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
@spaces.GPU
def ask_question(question, image):
image = Image.open(image).convert("RGB")
response = model.ask_question(question, image)
return response
# Create the Gradio interface
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."
)
# Launch the interface with API enabled
interface.launch()
|