File size: 590 Bytes
d52eb24
 
eef44a6
 
d52eb24
46809cd
d52eb24
eef44a6
 
 
 
 
 
 
 
d52eb24
 
 
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-git-large-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()