| 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() |