File size: 585 Bytes
aac2f1c 3376fed aac2f1c 3376fed aac2f1c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import gradio as gr
from transformers import pipeline
from PIL import Image
import numpy as np
pipe = pipeline("image-to-text", model="daniyal214/finetuned-blip-chest-xrays")
def get_captions(input_image):
# Convert the received image to a PIL Image
image = Image.fromarray((input_image * 255).astype(np.uint8))
# Pass the PIL image to the pipeline
result = pipe(image)
result = result[0]['generated_text']
return result
iface = gr.Interface(fn = get_captions, inputs = "image", outputs = ['text'], title="X-rays Image Caption Generator")
iface.launch() |